@ohif/app 3.10.0-beta.113 → 3.10.0-beta.115

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 (66) hide show
  1. package/dist/1568.bundle.af4308b321dfab0445e6.js +6562 -0
  2. package/dist/{1919.bundle.fae108d3c6ad35ed05ae.js → 1919.bundle.8bd683b21cbfe1cb71a7.js} +12 -8
  3. package/dist/1919.css +1 -1
  4. package/dist/{870.bundle.26a075bb828c43c13794.js → 2308.bundle.8db15bbd9d5833f21526.js} +54 -135
  5. package/dist/{870.css → 2308.css} +1 -1
  6. package/dist/{2701.bundle.c9ea5a2bd0df31dd3aaa.js → 2701.bundle.b68c4419910024a0758d.js} +14 -10
  7. package/dist/3480.bundle.22f8a106b17da4d7e826.js +7495 -0
  8. package/dist/{3677.bundle.22ecea02fae99fc4b073.js → 3677.bundle.4a319db2fd495efa4564.js} +1648 -1654
  9. package/dist/{5770.bundle.700382010763de7c58fd.js → 4113.bundle.8fccd7af6118fde173aa.js} +34 -80
  10. package/dist/{4202.bundle.add83801fbc8227d551b.js → 4202.bundle.c86958c59da67316127c.js} +1 -1
  11. package/dist/{4526.bundle.bf1047785c90ef0a9fec.js → 4526.bundle.7b394677fd5dc4fad06f.js} +6 -6
  12. package/dist/{99.bundle.f7e8de6d86029ec75605.js → 4675.bundle.b7e00e5915520885fa1f.js} +967 -2
  13. package/dist/4743.bundle.9faa6ddab058d9a939f4.js +6634 -0
  14. package/dist/{4759.bundle.0d60078f58f5a56c0157.js → 4759.bundle.e4ff22f9db3f555aad7b.js} +4 -0
  15. package/dist/4759.css +1 -1
  16. package/dist/{2236.bundle.2fbf9a607e380f3bdd7f.js → 4789.bundle.5bc2d9e5507319d9cadf.js} +22327 -22350
  17. package/dist/{4834.bundle.750ec176d0ef84772b0a.js → 4834.bundle.6b5e7e0fc3343ec1960a.js} +1 -1
  18. package/dist/{4991.bundle.aa561005b9bff1f391af.js → 4991.bundle.897fe8cb1e85dbf31543.js} +4 -0
  19. package/dist/5258.bundle.f95ab2e02467a734bdb6.js +4519 -0
  20. package/dist/{5915.bundle.84b8c2aa4d4a8c7e40a2.js → 5341.bundle.2f963b49a4856e342cd1.js} +48327 -48879
  21. package/dist/{5674.bundle.05e639d0871778c8093a.js → 5674.bundle.977cff87c10fbb29cbb3.js} +4 -0
  22. package/dist/5674.css +1 -1
  23. package/dist/{573.bundle.ae0bd4f3e1f4eac8ae43.js → 573.bundle.9549b3f7fa44438654f0.js} +1 -1
  24. package/dist/{6027.bundle.32be836eef7308434394.js → 6027.bundle.d85e8a6bae1085cda03e.js} +3 -5
  25. package/dist/{8888.bundle.f6a648dc743772c89787.js → 6139.bundle.12d9035382cda028683b.js} +26538 -32458
  26. package/dist/{6201.bundle.11e6c535543d13b0bb98.js → 6201.bundle.db75c77eb056cb88c2b0.js} +4 -4
  27. package/dist/6201.css +1 -1
  28. package/dist/{6341.bundle.5e868cc5104bc834fcbc.js → 6341.bundle.40ae99e784ab35e9407c.js} +11 -21
  29. package/dist/6341.css +1 -1
  30. package/dist/{5038.bundle.790dfe509bc9841701b0.js → 6727.bundle.ffc91186f23237ec35c4.js} +4022 -11619
  31. package/dist/{6734.bundle.1a6cfb006f9a16963b0d.js → 6734.bundle.6829e6ba782c290fb687.js} +2 -2
  32. package/dist/6734.css +1 -1
  33. package/dist/6752.bundle.e33e02dd8f006be51464.js +2249 -0
  34. package/dist/{7197.bundle.3503d1951304cac940fa.js → 7197.bundle.e8529fdc03c3cc927e38.js} +50 -41
  35. package/dist/7197.css +1 -1
  36. package/dist/{5692.bundle.22ae2ac093b6d6b65a6e.js → 7942.bundle.a76695b6bc780cbf0b23.js} +474 -513
  37. package/dist/{8008.bundle.74e51bdb02ff5d264f50.js → 8008.bundle.bbb188c7a9c5358b5682.js} +4 -9
  38. package/dist/{810.bundle.342fc8fac8ae665558c6.js → 810.bundle.e388d7b970d9622441c4.js} +10 -10
  39. package/dist/810.css +1 -1
  40. package/dist/{8228.bundle.4bcb42b49355447ef23c.js → 8228.bundle.9532c8d75799a8d9c093.js} +2 -2
  41. package/dist/{8259.bundle.39723f9c04717f80687e.js → 8259.bundle.0f474d990a129494e1df.js} +3 -3
  42. package/dist/8402.css +1 -1
  43. package/dist/{8558.bundle.56d667a6969a60bab102.js → 8558.bundle.ffb653dfb0104bdd128e.js} +5 -1
  44. package/dist/8834.bundle.88696f3afc37982b4273.js +14581 -0
  45. package/dist/{9026.bundle.90271a421048d1adc3db.js → 9026.bundle.317d3f9be65ef67b9bff.js} +15 -10
  46. package/dist/{9551.bundle.44d1426054e46cf5d673.js → 9551.bundle.92b13000deb4aa87f2fd.js} +4 -9
  47. package/dist/{9072.bundle.49293623f9ed4582eeeb.js → 9855.bundle.ba46a4315a78373262ad.js} +451 -393
  48. package/dist/{9862.bundle.a4ccc41bcff91a46d37e.js → 9862.bundle.e44946f8d28ded1e722f.js} +3 -3
  49. package/dist/{9890.bundle.07483064f31feb5718a4.js → 9890.bundle.711bf3486194cdd5c039.js} +6 -6
  50. package/dist/9890.css +1 -1
  51. package/dist/app-config.js +8 -1
  52. package/dist/{app.bundle.3dc9aa5b6077224cc394.js → app.bundle.aac0f76ff17b3e978aa1.js} +55160 -53512
  53. package/dist/app.bundle.css +2 -2
  54. package/dist/{polySeg.bundle.d41f5224f4efc124505a.js → compute.bundle.fa052dcf2ef82b4950ad.js} +4 -3
  55. package/dist/{histogram-worker.bundle.6b0dbbdb168d711efad4.js → histogram-worker.bundle.986106c30f091f2cef47.js} +2 -1
  56. package/dist/index.html +1 -1
  57. package/dist/polySeg.bundle.7d21e7dc9b361089e3a5.js +250 -0
  58. package/dist/{suv-peak-worker.bundle.4ca63044b76f51350d34.js → suv-peak-worker.bundle.f22f853b6599f7ec6f0c.js} +6 -5
  59. package/dist/sw.js +1 -1
  60. package/package.json +19 -19
  61. package/dist/2045.bundle.aaa10dff6d93bec47a45.js +0 -9708
  62. package/dist/6896.bundle.ca9b905abe733f279387.js +0 -7147
  63. /package/dist/{213.bundle.a98935570805e4a7b9b2.js → 213.bundle.533d331e72ec5aa85b1c.js} +0 -0
  64. /package/dist/{2424.bundle.4f1eeae6a8f248dd34c1.js → 2424.bundle.4f39ac6cdb1a28a0ded3.js} +0 -0
  65. /package/dist/{2825.bundle.a9ed7e8b46a92a157797.js → 2825.bundle.f6bfd4cc1a286ebb1b38.js} +0 -0
  66. /package/dist/{7955.bundle.eba45d4238f7e762545d.js → 7955.bundle.24dbe9de87056ecbb422.js} +0 -0
@@ -0,0 +1,4519 @@
1
+ "use strict";
2
+ (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[5258],{
3
+
4
+ /***/ 81985:
5
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6
+
7
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8
+ /* harmony export */ BaseVolumeViewport: () => (/* reexport safe */ _RenderingEngine_BaseVolumeViewport__WEBPACK_IMPORTED_MODULE_8__.A),
9
+ /* harmony export */ CONSTANTS: () => (/* reexport module object */ _constants__WEBPACK_IMPORTED_MODULE_1__),
10
+ /* harmony export */ Enums: () => (/* reexport module object */ _enums__WEBPACK_IMPORTED_MODULE_0__),
11
+ /* harmony export */ Settings: () => (/* reexport safe */ _Settings__WEBPACK_IMPORTED_MODULE_22__.A),
12
+ /* harmony export */ StackViewport: () => (/* reexport safe */ _RenderingEngine_StackViewport__WEBPACK_IMPORTED_MODULE_9__.A),
13
+ /* harmony export */ VideoViewport: () => (/* reexport safe */ _RenderingEngine_VideoViewport__WEBPACK_IMPORTED_MODULE_10__.A),
14
+ /* harmony export */ VolumeViewport: () => (/* reexport safe */ _RenderingEngine_VolumeViewport__WEBPACK_IMPORTED_MODULE_6__.A),
15
+ /* harmony export */ addImageSlicesToViewports: () => (/* reexport safe */ _RenderingEngine_helpers__WEBPACK_IMPORTED_MODULE_31__.ge),
16
+ /* harmony export */ addVolumesToViewports: () => (/* reexport safe */ _RenderingEngine_helpers__WEBPACK_IMPORTED_MODULE_31__.x),
17
+ /* harmony export */ cache: () => (/* reexport safe */ _cache_cache__WEBPACK_IMPORTED_MODULE_16__.Ay),
18
+ /* harmony export */ convertMapperToNotSharedMapper: () => (/* reexport safe */ _RenderingEngine_helpers_createVolumeMapper__WEBPACK_IMPORTED_MODULE_4__.h),
19
+ /* harmony export */ createVolumeActor: () => (/* reexport safe */ _RenderingEngine_helpers_createVolumeActor__WEBPACK_IMPORTED_MODULE_3__.A),
20
+ /* harmony export */ eventTarget: () => (/* reexport safe */ _eventTarget__WEBPACK_IMPORTED_MODULE_13__.A),
21
+ /* harmony export */ getEnabledElement: () => (/* reexport safe */ _getEnabledElement__WEBPACK_IMPORTED_MODULE_19__.Ay),
22
+ /* harmony export */ getEnabledElementByIds: () => (/* reexport safe */ _getEnabledElement__WEBPACK_IMPORTED_MODULE_19__.b1),
23
+ /* harmony export */ getEnabledElementByViewportId: () => (/* reexport safe */ _getEnabledElement__WEBPACK_IMPORTED_MODULE_19__.yj),
24
+ /* harmony export */ getEnabledElements: () => (/* reexport safe */ _getEnabledElement__WEBPACK_IMPORTED_MODULE_19__.zb),
25
+ /* harmony export */ getRenderingEngine: () => (/* reexport safe */ _RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_14__.lD),
26
+ /* harmony export */ getRenderingEngines: () => (/* reexport safe */ _RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_14__.qO),
27
+ /* harmony export */ getWebWorkerManager: () => (/* reexport safe */ _init__WEBPACK_IMPORTED_MODULE_21__.G_),
28
+ /* harmony export */ imageLoadPoolManager: () => (/* reexport safe */ _requestPool_imageLoadPoolManager__WEBPACK_IMPORTED_MODULE_18__.A),
29
+ /* harmony export */ imageLoader: () => (/* reexport module object */ _loaders_imageLoader__WEBPACK_IMPORTED_MODULE_24__),
30
+ /* harmony export */ metaData: () => (/* reexport module object */ _metaData__WEBPACK_IMPORTED_MODULE_20__),
31
+ /* harmony export */ triggerEvent: () => (/* reexport safe */ _utilities_triggerEvent__WEBPACK_IMPORTED_MODULE_28__.A),
32
+ /* harmony export */ utilities: () => (/* reexport module object */ _utilities__WEBPACK_IMPORTED_MODULE_27__),
33
+ /* harmony export */ volumeLoader: () => (/* reexport module object */ _loaders_volumeLoader__WEBPACK_IMPORTED_MODULE_23__)
34
+ /* harmony export */ });
35
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(31749);
36
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(19325);
37
+ /* harmony import */ var _RenderingEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(56706);
38
+ /* harmony import */ var _RenderingEngine_helpers_createVolumeActor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(61640);
39
+ /* harmony import */ var _RenderingEngine_helpers_createVolumeMapper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(92099);
40
+ /* harmony import */ var _RenderingEngine_helpers_getOrCreateCanvas__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(30135);
41
+ /* harmony import */ var _RenderingEngine_VolumeViewport__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(94155);
42
+ /* harmony import */ var _RenderingEngine_VolumeViewport3D__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(40893);
43
+ /* harmony import */ var _RenderingEngine_BaseVolumeViewport__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(46347);
44
+ /* harmony import */ var _RenderingEngine_StackViewport__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(58165);
45
+ /* harmony import */ var _RenderingEngine_VideoViewport__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(32501);
46
+ /* harmony import */ var _RenderingEngine_WSIViewport__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(81466);
47
+ /* harmony import */ var _RenderingEngine_Viewport__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(10056);
48
+ /* harmony import */ var _eventTarget__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(10364);
49
+ /* harmony import */ var _RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(39536);
50
+ /* harmony import */ var _cache__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(58927);
51
+ /* harmony import */ var _cache_cache__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(49038);
52
+ /* harmony import */ var _requestPool_imageRetrievalPoolManager__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(91073);
53
+ /* harmony import */ var _requestPool_imageLoadPoolManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(51159);
54
+ /* harmony import */ var _getEnabledElement__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(86846);
55
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(74876);
56
+ /* harmony import */ var _init__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(59693);
57
+ /* harmony import */ var _Settings__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(57308);
58
+ /* harmony import */ var _loaders_volumeLoader__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(39561);
59
+ /* harmony import */ var _loaders_imageLoader__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(80068);
60
+ /* harmony import */ var _loaders_geometryLoader__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(89926);
61
+ /* harmony import */ var _loaders_ProgressiveRetrieveImages__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(36822);
62
+ /* harmony import */ var _utilities__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(98866);
63
+ /* harmony import */ var _utilities_triggerEvent__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(69372);
64
+ /* harmony import */ var _loaders_cornerstoneStreamingImageVolumeLoader__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(55500);
65
+ /* harmony import */ var _loaders_cornerstoneStreamingDynamicImageVolumeLoader__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(55509);
66
+ /* harmony import */ var _RenderingEngine_helpers__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(40661);
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+
103
+
104
+ /***/ }),
105
+
106
+ /***/ 82918:
107
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
108
+
109
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
110
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
111
+ /* harmony export */ });
112
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
113
+ /* harmony import */ var _spatialRegistrationMetadataProvider__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(40239);
114
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(74876);
115
+
116
+
117
+
118
+ const ALLOWED_DELTA = 0.05;
119
+ function calculateViewportsSpatialRegistration(viewport1, viewport2) {
120
+ const imageId1 = viewport1.getSliceIndex();
121
+ const imageId2 = viewport2.getSliceIndex();
122
+ const imagePlaneModule1 = (0,_metaData__WEBPACK_IMPORTED_MODULE_2__.get)('imagePlaneModule', imageId1.toString());
123
+ const imagePlaneModule2 = (0,_metaData__WEBPACK_IMPORTED_MODULE_2__.get)('imagePlaneModule', imageId2.toString());
124
+ if (!imagePlaneModule1 || !imagePlaneModule2) {
125
+ console.log('Viewport spatial registration requires image plane module');
126
+ return;
127
+ }
128
+ const { imageOrientationPatient: iop2 } = imagePlaneModule2;
129
+ const isSameImagePlane = imagePlaneModule1.imageOrientationPatient.every((v, i) => Math.abs(v - iop2[i]) < ALLOWED_DELTA);
130
+ if (!isSameImagePlane) {
131
+ console.log('Viewport spatial registration only supported for same orientation (hence translation only) for now', imagePlaneModule1?.imageOrientationPatient, imagePlaneModule2?.imageOrientationPatient);
132
+ return;
133
+ }
134
+ const imagePositionPatient1 = imagePlaneModule1.imagePositionPatient;
135
+ const imagePositionPatient2 = imagePlaneModule2.imagePositionPatient;
136
+ const translation = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.subtract */ .eR.subtract(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), imagePositionPatient1, imagePositionPatient2);
137
+ const mat = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat4.fromTranslation */ .pB.fromTranslation(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat4.create */ .pB.create(), translation);
138
+ _spatialRegistrationMetadataProvider__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A.add([viewport1.id, viewport2.id], mat);
139
+ }
140
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (calculateViewportsSpatialRegistration);
141
+
142
+
143
+ /***/ }),
144
+
145
+ /***/ 73822:
146
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
147
+
148
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
149
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
150
+ /* harmony export */ });
151
+ /* harmony import */ var _imageIdToURI__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(39537);
152
+
153
+ const state = {};
154
+ const metadataProvider = {
155
+ add: (imageId, payload) => {
156
+ const imageURI = (0,_imageIdToURI__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(imageId);
157
+ state[imageURI] = payload;
158
+ },
159
+ get: (type, imageId) => {
160
+ if (type === 'calibratedPixelSpacing') {
161
+ const imageURI = (0,_imageIdToURI__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(imageId);
162
+ return state[imageURI];
163
+ }
164
+ },
165
+ };
166
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (metadataProvider);
167
+
168
+
169
+ /***/ }),
170
+
171
+ /***/ 84061:
172
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
173
+
174
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
175
+ /* harmony export */ A: () => (/* binding */ clamp),
176
+ /* harmony export */ q: () => (/* binding */ clamp)
177
+ /* harmony export */ });
178
+ function clamp(value, min, max) {
179
+ return Math.max(min, Math.min(max, value));
180
+ }
181
+
182
+
183
+
184
+ /***/ }),
185
+
186
+ /***/ 25534:
187
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
188
+
189
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
190
+ /* harmony export */ Ay: () => (__WEBPACK_DEFAULT_EXPORT__)
191
+ /* harmony export */ });
192
+ /* unused harmony exports clip, clipToBox */
193
+ function clip(val, low, high) {
194
+ return Math.min(Math.max(low, val), high);
195
+ }
196
+ function clipToBox(point, box) {
197
+ point.x = clip(point.x, 0, box.width);
198
+ point.y = clip(point.y, 0, box.height);
199
+ }
200
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (clip);
201
+
202
+
203
+ /***/ }),
204
+
205
+ /***/ 79717:
206
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
207
+
208
+ __webpack_require__.r(__webpack_exports__);
209
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
210
+ /* harmony export */ hexToRgb: () => (/* binding */ hexToRgb),
211
+ /* harmony export */ rgbToHex: () => (/* binding */ rgbToHex)
212
+ /* harmony export */ });
213
+ function componentToHex(c) {
214
+ const hex = c.toString(16);
215
+ return hex.length == 1 ? '0' + hex : hex;
216
+ }
217
+ function rgbToHex(r, g, b) {
218
+ return '#' + componentToHex(r) + componentToHex(g) + componentToHex(b);
219
+ }
220
+ function hexToRgb(hex) {
221
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
222
+ return result
223
+ ? {
224
+ r: parseInt(result[1], 16),
225
+ g: parseInt(result[2], 16),
226
+ b: parseInt(result[3], 16),
227
+ }
228
+ : null;
229
+ }
230
+
231
+
232
+
233
+ /***/ }),
234
+
235
+ /***/ 13859:
236
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
237
+
238
+ __webpack_require__.r(__webpack_exports__);
239
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
240
+ /* harmony export */ findMatchingColormap: () => (/* binding */ findMatchingColormap),
241
+ /* harmony export */ getColormap: () => (/* binding */ getColormap),
242
+ /* harmony export */ getColormapNames: () => (/* binding */ getColormapNames),
243
+ /* harmony export */ registerColormap: () => (/* binding */ registerColormap)
244
+ /* harmony export */ });
245
+ /* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction_ColorMaps__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(660);
246
+ /* harmony import */ var _isEqual__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(74638);
247
+ /* harmony import */ var _actorCheck__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(98039);
248
+
249
+
250
+
251
+ const _colormaps = new Map();
252
+ function registerColormap(colormap) {
253
+ _colormaps.set(colormap.Name, colormap);
254
+ }
255
+ function getColormap(name) {
256
+ return _colormaps.get(name);
257
+ }
258
+ function getColormapNames() {
259
+ return Array.from(_colormaps.keys());
260
+ }
261
+ function findMatchingColormap(rgbPoints, actor) {
262
+ const colormapsVTK = _kitware_vtk_js_Rendering_Core_ColorTransferFunction_ColorMaps__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.rgbPresetNames.map((presetName) => _kitware_vtk_js_Rendering_Core_ColorTransferFunction_ColorMaps__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.getPresetByName(presetName));
263
+ const colormapsCS3D = getColormapNames().map((colormapName) => getColormap(colormapName));
264
+ const colormaps = colormapsVTK.concat(colormapsCS3D);
265
+ const matchedColormap = colormaps.find((colormap) => {
266
+ const { RGBPoints: presetRGBPoints } = colormap;
267
+ if (presetRGBPoints.length !== rgbPoints.length) {
268
+ return false;
269
+ }
270
+ for (let i = 0; i < presetRGBPoints.length; i += 4) {
271
+ if (!(0,_isEqual__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Ay)(presetRGBPoints.slice(i + 1, i + 4), rgbPoints.slice(i + 1, i + 4))) {
272
+ return false;
273
+ }
274
+ }
275
+ return true;
276
+ });
277
+ if (!matchedColormap) {
278
+ return null;
279
+ }
280
+ const opacity = [];
281
+ if ((0,_actorCheck__WEBPACK_IMPORTED_MODULE_2__/* .actorIsA */ .N)(actor, 'vtkVolume')) {
282
+ const opacityPoints = actor
283
+ .getProperty()
284
+ .getScalarOpacity(0)
285
+ .getDataPointer();
286
+ if (!opacityPoints) {
287
+ return {
288
+ name: matchedColormap.Name,
289
+ };
290
+ }
291
+ for (let i = 0; i < opacityPoints.length; i += 2) {
292
+ opacity.push({
293
+ value: opacityPoints[i],
294
+ opacity: opacityPoints[i + 1],
295
+ });
296
+ }
297
+ }
298
+ return {
299
+ name: matchedColormap.Name,
300
+ opacity,
301
+ };
302
+ }
303
+
304
+
305
+
306
+ /***/ }),
307
+
308
+ /***/ 86888:
309
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
310
+
311
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
312
+ /* harmony export */ h: () => (/* binding */ convertStackToVolumeViewport)
313
+ /* harmony export */ });
314
+ /* harmony import */ var _RenderingEngine_helpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40661);
315
+ /* harmony import */ var _loaders_volumeLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(39561);
316
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(31749);
317
+ /* harmony import */ var _uuidv4__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(80221);
318
+
319
+
320
+
321
+
322
+ async function convertStackToVolumeViewport({ viewport, options = {}, }) {
323
+ const renderingEngine = viewport.getRenderingEngine();
324
+ let volumeId = options.volumeId || `${(0,_uuidv4__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A)()}`;
325
+ if (volumeId.split(':').length === 0) {
326
+ const schema = (0,_loaders_volumeLoader__WEBPACK_IMPORTED_MODULE_1__.getUnknownVolumeLoaderSchema)();
327
+ volumeId = `${schema}:${volumeId}`;
328
+ }
329
+ const { id, element } = viewport;
330
+ const viewportId = options.viewportId || id;
331
+ const imageIds = viewport.getImageIds();
332
+ const prevViewPresentation = viewport.getViewPresentation();
333
+ const prevViewReference = viewport.getViewReference();
334
+ renderingEngine.enableElement({
335
+ viewportId,
336
+ type: _enums__WEBPACK_IMPORTED_MODULE_2__.ViewportType.ORTHOGRAPHIC,
337
+ element,
338
+ defaultOptions: {
339
+ background: options.background,
340
+ orientation: options.orientation,
341
+ },
342
+ });
343
+ const volume = (await (0,_loaders_volumeLoader__WEBPACK_IMPORTED_MODULE_1__.createAndCacheVolume)(volumeId, {
344
+ imageIds,
345
+ }));
346
+ volume.load();
347
+ const volumeViewport = renderingEngine.getViewport(viewportId);
348
+ await (0,_RenderingEngine_helpers__WEBPACK_IMPORTED_MODULE_0__/* .setVolumesForViewports */ .A7)(renderingEngine, [
349
+ {
350
+ volumeId,
351
+ },
352
+ ], [viewportId]);
353
+ const volumeViewportNewVolumeHandler = () => {
354
+ volumeViewport.render();
355
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_2__.Events.VOLUME_VIEWPORT_NEW_VOLUME, volumeViewportNewVolumeHandler);
356
+ };
357
+ const addVolumeViewportNewVolumeListener = () => {
358
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_2__.Events.VOLUME_VIEWPORT_NEW_VOLUME, volumeViewportNewVolumeHandler);
359
+ };
360
+ addVolumeViewportNewVolumeListener();
361
+ volumeViewport.setViewPresentation(prevViewPresentation);
362
+ volumeViewport.setViewReference(prevViewReference);
363
+ volumeViewport.render();
364
+ return volumeViewport;
365
+ }
366
+
367
+
368
+
369
+ /***/ }),
370
+
371
+ /***/ 2397:
372
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
373
+
374
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
375
+ /* harmony export */ A: () => (/* binding */ convertToGrayscale)
376
+ /* harmony export */ });
377
+ function convertToGrayscale(scalarData, width, height) {
378
+ const isRGBA = scalarData.length === width * height * 4;
379
+ const isRGB = scalarData.length === width * height * 3;
380
+ if (isRGBA || isRGB) {
381
+ const newScalarData = new Float32Array(width * height);
382
+ let offset = 0;
383
+ let destOffset = 0;
384
+ const increment = isRGBA ? 4 : 3;
385
+ for (let x = 0; x < width; x++) {
386
+ for (let y = 0; y < height; y++) {
387
+ const r = scalarData[offset];
388
+ const g = scalarData[offset + 1];
389
+ const b = scalarData[offset + 2];
390
+ newScalarData[destOffset] = (r + g + b) / 3;
391
+ offset += increment;
392
+ destOffset++;
393
+ }
394
+ }
395
+ return newScalarData;
396
+ }
397
+ else {
398
+ return scalarData;
399
+ }
400
+ }
401
+
402
+
403
+ /***/ }),
404
+
405
+ /***/ 47442:
406
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
407
+
408
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
409
+ /* harmony export */ n: () => (/* binding */ convertVolumeToStackViewport)
410
+ /* harmony export */ });
411
+ /* harmony import */ var _cache_cache__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(49038);
412
+ /* harmony import */ var _cache_classes_ImageVolume__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(86252);
413
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(31749);
414
+
415
+
416
+
417
+ async function convertVolumeToStackViewport({ viewport, options, }) {
418
+ const volumeViewport = viewport;
419
+ const { id, element } = volumeViewport;
420
+ const renderingEngine = viewport.getRenderingEngine();
421
+ const { background } = options;
422
+ const viewportId = options.viewportId || id;
423
+ const volume = _cache_cache__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Ay.getVolume(volumeViewport.getVolumeId());
424
+ if (!(volume instanceof _cache_classes_ImageVolume__WEBPACK_IMPORTED_MODULE_1__/* .ImageVolume */ .Q)) {
425
+ throw new Error('Currently, you cannot decache a volume that is not an ImageVolume. So, unfortunately, volumes such as nifti (which are basic Volume, without imageIds) cannot be decached.');
426
+ }
427
+ const viewportInput = {
428
+ viewportId,
429
+ type: _enums__WEBPACK_IMPORTED_MODULE_2__.ViewportType.STACK,
430
+ element,
431
+ defaultOptions: {
432
+ background,
433
+ },
434
+ };
435
+ const prevView = volumeViewport.getViewReference();
436
+ renderingEngine.enableElement(viewportInput);
437
+ const stackViewport = renderingEngine.getViewport(viewportId);
438
+ await stackViewport.setStack(volume.imageIds);
439
+ stackViewport.setViewReference(prevView);
440
+ stackViewport.render();
441
+ return stackViewport;
442
+ }
443
+
444
+
445
+
446
+ /***/ }),
447
+
448
+ /***/ 23586:
449
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
450
+
451
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
452
+ /* harmony export */ A: () => (/* binding */ createSubVolume)
453
+ /* harmony export */ });
454
+ /* unused harmony export createSubVolume */
455
+ /* harmony import */ var _transformWorldToIndex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(38669);
456
+ /* harmony import */ var _transformIndexToWorld__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(94741);
457
+ /* harmony import */ var _uuidv4__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(80221);
458
+ /* harmony import */ var _loaders_volumeLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(39561);
459
+ /* harmony import */ var _cache_cache__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(49038);
460
+
461
+
462
+
463
+
464
+
465
+ function createSubVolume(referencedVolumeId, boundsIJK, options = {}) {
466
+ const referencedVolume = _cache_cache__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Ay.getVolume(referencedVolumeId);
467
+ if (!referencedVolume) {
468
+ throw new Error(`Referenced volume with id ${referencedVolumeId} does not exist.`);
469
+ }
470
+ const { metadata, spacing, direction, dimensions: refVolumeDim, } = referencedVolume;
471
+ const { minX, maxX, minY, maxY, minZ, maxZ } = boundsIJK;
472
+ const ijkTopLeft = [
473
+ Math.min(minX, maxX),
474
+ Math.min(minY, maxY),
475
+ Math.min(minZ, maxZ),
476
+ ];
477
+ const boundingBoxOriginWorld = (0,_transformIndexToWorld__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)(referencedVolume.imageData, ijkTopLeft);
478
+ const dimensions = [
479
+ Math.abs(maxX - minX) + 1,
480
+ Math.abs(maxY - minY) + 1,
481
+ Math.abs(maxZ - minZ) + 1,
482
+ ];
483
+ const { targetBuffer } = options;
484
+ const subVolumeOptions = {
485
+ metadata,
486
+ dimensions,
487
+ spacing,
488
+ origin: boundingBoxOriginWorld,
489
+ direction,
490
+ targetBuffer,
491
+ scalarData: targetBuffer?.type === 'Float32Array'
492
+ ? new Float32Array(dimensions[0] * dimensions[1] * dimensions[2])
493
+ : undefined,
494
+ };
495
+ const subVolume = (0,_loaders_volumeLoader__WEBPACK_IMPORTED_MODULE_3__.createLocalVolume)((0,_uuidv4__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A)(), subVolumeOptions);
496
+ const subVolumeData = subVolume.voxelManager.getCompleteScalarDataArray();
497
+ const subVolumeSliceSize = dimensions[0] * dimensions[1];
498
+ const refVolumeSliceSize = refVolumeDim[0] * refVolumeDim[1];
499
+ const refVolumeData = referencedVolume.voxelManager.getCompleteScalarDataArray();
500
+ for (let z = 0; z < dimensions[2]; z++) {
501
+ for (let y = 0; y < dimensions[1]; y++) {
502
+ const rowStartWorld = (0,_transformIndexToWorld__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)(subVolume.imageData, [
503
+ 0,
504
+ y,
505
+ z,
506
+ ]);
507
+ const refVolumeRowStartIJK = (0,_transformWorldToIndex__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(referencedVolume.imageData, rowStartWorld);
508
+ const refVolumeRowStartOffset = refVolumeRowStartIJK[2] * refVolumeSliceSize +
509
+ refVolumeRowStartIJK[1] * refVolumeDim[0] +
510
+ refVolumeRowStartIJK[0];
511
+ const rowData = refVolumeData.slice(refVolumeRowStartOffset, refVolumeRowStartOffset + dimensions[0]);
512
+ const subVolumeLineStartOffset = z * subVolumeSliceSize + y * dimensions[0];
513
+ subVolumeData.set(rowData, subVolumeLineStartOffset);
514
+ }
515
+ }
516
+ subVolume.voxelManager.setCompleteScalarDataArray(subVolumeData);
517
+ return subVolume;
518
+ }
519
+
520
+
521
+
522
+ /***/ }),
523
+
524
+ /***/ 13148:
525
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
526
+
527
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
528
+ /* harmony export */ b: () => (/* binding */ deepEqual)
529
+ /* harmony export */ });
530
+ function deepEqual(obj1, obj2) {
531
+ if (obj1 === obj2) {
532
+ return true;
533
+ }
534
+ if (obj1 == null || obj2 == null) {
535
+ return false;
536
+ }
537
+ try {
538
+ return JSON.stringify(obj1) === JSON.stringify(obj2);
539
+ }
540
+ catch (error) {
541
+ console.debug('Error in JSON.stringify during deep comparison:', error);
542
+ return obj1 === obj2;
543
+ }
544
+ }
545
+
546
+
547
+ /***/ }),
548
+
549
+ /***/ 94015:
550
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
551
+
552
+ // ESM COMPAT FLAG
553
+ __webpack_require__.r(__webpack_exports__);
554
+
555
+ // EXPORTS
556
+ __webpack_require__.d(__webpack_exports__, {
557
+ MultiTargetEventListenerManager: () => (/* reexport */ MultiTargetEventListenerManager),
558
+ TargetEventListeners: () => (/* reexport */ TargetEventListeners)
559
+ });
560
+
561
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/utilities/eventListener/TargetEventListeners.js
562
+ var EventListenerPhases;
563
+ (function (EventListenerPhases) {
564
+ EventListenerPhases[EventListenerPhases["None"] = 0] = "None";
565
+ EventListenerPhases[EventListenerPhases["Capture"] = 1] = "Capture";
566
+ EventListenerPhases[EventListenerPhases["Bubble"] = 2] = "Bubble";
567
+ })(EventListenerPhases || (EventListenerPhases = {}));
568
+ class TargetEventListeners {
569
+ constructor(target) {
570
+ this._eventListeners = new Map();
571
+ this._children = new Map();
572
+ this._target = target;
573
+ }
574
+ get isEmpty() {
575
+ return this._eventListeners.size === 0 && this._children.size === 0;
576
+ }
577
+ addEventListener(type, callback, options) {
578
+ const dotIndex = type.indexOf('.');
579
+ const isNamespace = dotIndex !== -1;
580
+ if (isNamespace) {
581
+ const namespaceToken = type.substring(0, dotIndex);
582
+ let childElementEventListener = this._children.get(namespaceToken);
583
+ if (!childElementEventListener) {
584
+ childElementEventListener = new TargetEventListeners(this._target);
585
+ this._children.set(namespaceToken, childElementEventListener);
586
+ }
587
+ type = type.substring(dotIndex + 1);
588
+ childElementEventListener.addEventListener(type, callback, options);
589
+ }
590
+ else {
591
+ this._addEventListener(type, callback, options);
592
+ }
593
+ }
594
+ removeEventListener(type, callback, options) {
595
+ const dotIndex = type.indexOf('.');
596
+ const isNamespace = dotIndex !== -1;
597
+ if (isNamespace) {
598
+ const namespaceToken = type.substring(0, dotIndex);
599
+ const childElementEventListener = this._children.get(namespaceToken);
600
+ if (!childElementEventListener) {
601
+ return;
602
+ }
603
+ type = type.substring(dotIndex + 1);
604
+ childElementEventListener.removeEventListener(type, callback, options);
605
+ if (childElementEventListener.isEmpty) {
606
+ this._children.delete(namespaceToken);
607
+ }
608
+ }
609
+ else {
610
+ this._removeEventListener(type, callback, options);
611
+ }
612
+ }
613
+ reset() {
614
+ Array.from(this._children.entries()).forEach(([namespace, child]) => {
615
+ child.reset();
616
+ if (child.isEmpty) {
617
+ this._children.delete(namespace);
618
+ }
619
+ else {
620
+ throw new Error('Child is not empty and cannot be removed');
621
+ }
622
+ });
623
+ this._unregisterAllEvents();
624
+ }
625
+ _addEventListener(type, callback, options) {
626
+ let listenersMap = this._eventListeners.get(type);
627
+ if (!listenersMap) {
628
+ listenersMap = new Map();
629
+ this._eventListeners.set(type, listenersMap);
630
+ }
631
+ const useCapture = options?.capture ?? false;
632
+ const listenerPhase = useCapture
633
+ ? EventListenerPhases.Capture
634
+ : EventListenerPhases.Bubble;
635
+ const registeredPhases = listenersMap.get(callback) ?? EventListenerPhases.None;
636
+ if (registeredPhases & listenerPhase) {
637
+ console.warn('A listener is already registered for this phase');
638
+ return;
639
+ }
640
+ listenersMap.set(callback, registeredPhases | listenerPhase);
641
+ this._target.addEventListener(type, callback, options);
642
+ }
643
+ _removeEventListener(type, callback, options) {
644
+ const useCapture = options?.capture ?? false;
645
+ const listenerPhase = useCapture
646
+ ? EventListenerPhases.Capture
647
+ : EventListenerPhases.Bubble;
648
+ const listenersMap = this._eventListeners.get(type);
649
+ if (!listenersMap) {
650
+ return;
651
+ }
652
+ const callbacks = callback ? [callback] : Array.from(listenersMap.keys());
653
+ callbacks.forEach((callbackItem) => {
654
+ const registeredPhases = listenersMap.get(callbackItem) ?? EventListenerPhases.None;
655
+ const phaseRegistered = !!(registeredPhases & listenerPhase);
656
+ if (!phaseRegistered) {
657
+ return;
658
+ }
659
+ this._target.removeEventListener(type, callbackItem, options);
660
+ const newListenerPhase = registeredPhases ^ listenerPhase;
661
+ if (newListenerPhase === EventListenerPhases.None) {
662
+ listenersMap.delete(callbackItem);
663
+ }
664
+ else {
665
+ listenersMap.set(callbackItem, newListenerPhase);
666
+ }
667
+ });
668
+ if (!listenersMap.size) {
669
+ this._eventListeners.delete(type);
670
+ }
671
+ }
672
+ _unregisterAllListeners(type, listenersMap) {
673
+ Array.from(listenersMap.entries()).forEach(([listener, eventPhases]) => {
674
+ const startPhase = EventListenerPhases.Capture;
675
+ for (let currentPhase = startPhase; eventPhases; currentPhase <<= 1) {
676
+ if (!(eventPhases & currentPhase)) {
677
+ continue;
678
+ }
679
+ const useCapture = currentPhase === EventListenerPhases.Capture ? true : false;
680
+ this.removeEventListener(type, listener, { capture: useCapture });
681
+ eventPhases ^= currentPhase;
682
+ }
683
+ });
684
+ }
685
+ _unregisterAllEvents() {
686
+ Array.from(this._eventListeners.entries()).forEach(([type, listenersMap]) => {
687
+ this._unregisterAllListeners(type, listenersMap);
688
+ });
689
+ }
690
+ }
691
+
692
+
693
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/utilities/eventListener/MultiTargetEventListenerManager.js
694
+
695
+ class MultiTargetEventListenerManager {
696
+ constructor() {
697
+ this._targetsEventListeners = new Map();
698
+ }
699
+ addEventListener(target, type, callback, options) {
700
+ let eventListeners = this._targetsEventListeners.get(target);
701
+ if (!eventListeners) {
702
+ eventListeners = new TargetEventListeners(target);
703
+ this._targetsEventListeners.set(target, eventListeners);
704
+ }
705
+ eventListeners.addEventListener(type, callback, options);
706
+ }
707
+ removeEventListener(target, type, callback, options) {
708
+ const eventListeners = this._targetsEventListeners.get(target);
709
+ if (!eventListeners) {
710
+ return;
711
+ }
712
+ eventListeners.removeEventListener(type, callback, options);
713
+ if (eventListeners.isEmpty) {
714
+ this._targetsEventListeners.delete(target);
715
+ }
716
+ }
717
+ reset() {
718
+ Array.from(this._targetsEventListeners.entries()).forEach(([target, targetEventListeners]) => {
719
+ targetEventListeners.reset();
720
+ this._targetsEventListeners.delete(target);
721
+ });
722
+ }
723
+ }
724
+
725
+
726
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/utilities/eventListener/index.js
727
+
728
+
729
+
730
+
731
+ /***/ }),
732
+
733
+ /***/ 27699:
734
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
735
+
736
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
737
+ /* harmony export */ A: () => (/* binding */ getClosestStackImageIndexForPoint)
738
+ /* harmony export */ });
739
+ /* unused harmony export calculateMinimalDistanceForStackViewport */
740
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
741
+ /* harmony import */ var _planar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(52268);
742
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(74876);
743
+
744
+
745
+
746
+ function getClosestStackImageIndexForPoint(point, viewport) {
747
+ const minimalDistance = calculateMinimalDistanceForStackViewport(point, viewport);
748
+ return minimalDistance ? minimalDistance.index : null;
749
+ }
750
+ function calculateMinimalDistanceForStackViewport(point, viewport) {
751
+ const imageIds = viewport.getImageIds();
752
+ const currentImageIdIndex = viewport.getCurrentImageIdIndex();
753
+ if (imageIds.length === 0) {
754
+ return null;
755
+ }
756
+ const getDistance = (imageId) => {
757
+ const planeMetadata = getPlaneMetadata(imageId);
758
+ if (!planeMetadata) {
759
+ return null;
760
+ }
761
+ const plane = _planar__WEBPACK_IMPORTED_MODULE_1__.planeEquation(planeMetadata.planeNormal, planeMetadata.imagePositionPatient);
762
+ const distance = _planar__WEBPACK_IMPORTED_MODULE_1__.planeDistanceToPoint(plane, point);
763
+ return distance;
764
+ };
765
+ const closestStack = {
766
+ distance: getDistance(imageIds[currentImageIdIndex]) ?? Infinity,
767
+ index: currentImageIdIndex,
768
+ };
769
+ const higherImageIds = imageIds.slice(currentImageIdIndex + 1);
770
+ for (let i = 0; i < higherImageIds.length; i++) {
771
+ const id = higherImageIds[i];
772
+ const distance = getDistance(id);
773
+ if (distance === null) {
774
+ continue;
775
+ }
776
+ if (distance <= closestStack.distance) {
777
+ closestStack.distance = distance;
778
+ closestStack.index = i + currentImageIdIndex + 1;
779
+ }
780
+ else {
781
+ break;
782
+ }
783
+ }
784
+ const lowerImageIds = imageIds.slice(0, currentImageIdIndex);
785
+ for (let i = lowerImageIds.length - 1; i >= 0; i--) {
786
+ const id = lowerImageIds[i];
787
+ const distance = getDistance(id);
788
+ if (distance === null || distance === closestStack.distance) {
789
+ continue;
790
+ }
791
+ if (distance < closestStack.distance) {
792
+ closestStack.distance = distance;
793
+ closestStack.index = i;
794
+ }
795
+ else {
796
+ break;
797
+ }
798
+ }
799
+ return closestStack.distance === Infinity ? null : closestStack;
800
+ }
801
+ function getPlaneMetadata(imageId) {
802
+ const targetImagePlane = _metaData__WEBPACK_IMPORTED_MODULE_2__.get('imagePlaneModule', imageId);
803
+ if (!targetImagePlane ||
804
+ !(targetImagePlane.rowCosines instanceof Array &&
805
+ targetImagePlane.rowCosines.length === 3) ||
806
+ !(targetImagePlane.columnCosines instanceof Array &&
807
+ targetImagePlane.columnCosines.length === 3) ||
808
+ !(targetImagePlane.imagePositionPatient instanceof Array &&
809
+ targetImagePlane.imagePositionPatient.length === 3)) {
810
+ return null;
811
+ }
812
+ const { rowCosines, columnCosines, imagePositionPatient, } = targetImagePlane;
813
+ const rowVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.set */ .eR.set(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), ...rowCosines);
814
+ const colVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.set */ .eR.set(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), ...columnCosines);
815
+ const planeNormal = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.cross */ .eR.cross(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), rowVec, colVec);
816
+ return { rowCosines, columnCosines, imagePositionPatient, planeNormal };
817
+ }
818
+
819
+
820
+ /***/ }),
821
+
822
+ /***/ 70683:
823
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
824
+
825
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
826
+ /* harmony export */ A: () => (/* binding */ getCurrentVolumeViewportSlice)
827
+ /* harmony export */ });
828
+ /* unused harmony export getCurrentVolumeViewportSlice */
829
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
830
+ /* harmony import */ var _transformCanvasToIJK__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(51919);
831
+
832
+
833
+ function getCurrentVolumeViewportSlice(viewport) {
834
+ const { width: canvasWidth, height: canvasHeight } = viewport.getCanvas();
835
+ const { sliceToIndexMatrix, indexToSliceMatrix } = viewport.getSliceViewInfo();
836
+ const ijkOriginPoint = (0,_transformCanvasToIJK__WEBPACK_IMPORTED_MODULE_1__/* .transformCanvasToIJK */ .e)(viewport, [0, 0]);
837
+ const ijkRowPoint = (0,_transformCanvasToIJK__WEBPACK_IMPORTED_MODULE_1__/* .transformCanvasToIJK */ .e)(viewport, [canvasWidth - 1, 0]);
838
+ const ijkColPoint = (0,_transformCanvasToIJK__WEBPACK_IMPORTED_MODULE_1__/* .transformCanvasToIJK */ .e)(viewport, [0, canvasHeight - 1]);
839
+ const ijkRowVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.sub */ .eR.sub(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), ijkRowPoint, ijkOriginPoint);
840
+ const ijkColVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.sub */ .eR.sub(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), ijkColPoint, ijkOriginPoint);
841
+ const ijkSliceVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.cross */ .eR.cross(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), ijkRowVec, ijkColVec);
842
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.normalize */ .eR.normalize(ijkRowVec, ijkRowVec);
843
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.normalize */ .eR.normalize(ijkColVec, ijkColVec);
844
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.normalize */ .eR.normalize(ijkSliceVec, ijkSliceVec);
845
+ const maxIJKRowVec = Math.max(Math.abs(ijkRowVec[0]), Math.abs(ijkRowVec[1]), Math.abs(ijkRowVec[2]));
846
+ const maxIJKColVec = Math.max(Math.abs(ijkColVec[0]), Math.abs(ijkColVec[1]), Math.abs(ijkColVec[2]));
847
+ if (!gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .glMatrix.equals */ .Fd.equals(1, maxIJKRowVec) || !gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .glMatrix.equals */ .Fd.equals(1, maxIJKColVec)) {
848
+ throw new Error('Livewire is not available for rotate/oblique viewports');
849
+ }
850
+ const { voxelManager } = viewport.getImageData();
851
+ const sliceViewInfo = viewport.getSliceViewInfo();
852
+ const scalarData = voxelManager.getSliceData(sliceViewInfo);
853
+ return {
854
+ width: sliceViewInfo.width,
855
+ height: sliceViewInfo.height,
856
+ scalarData,
857
+ sliceToIndexMatrix,
858
+ indexToSliceMatrix,
859
+ };
860
+ }
861
+
862
+
863
+
864
+ /***/ }),
865
+
866
+ /***/ 75283:
867
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
868
+
869
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
870
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
871
+ /* harmony export */ });
872
+ /* harmony import */ var _splitImageIdsBy4DTags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(31215);
873
+
874
+ function getDynamicVolumeInfo(imageIds) {
875
+ const { imageIdGroups: timePoints, splittingTag } = (0,_splitImageIdsBy4DTags__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(imageIds);
876
+ const isDynamicVolume = timePoints.length > 1;
877
+ return { isDynamicVolume, timePoints, splittingTag };
878
+ }
879
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (getDynamicVolumeInfo);
880
+
881
+
882
+ /***/ }),
883
+
884
+ /***/ 87594:
885
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
886
+
887
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
888
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
889
+ /* harmony export */ });
890
+ /* harmony import */ var _RenderingEngine_StackViewport__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(58165);
891
+ /* harmony import */ var _getEnabledElement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(86846);
892
+
893
+
894
+ function getImageLegacy(element) {
895
+ const enabledElement = (0,_getEnabledElement__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Ay)(element);
896
+ if (!enabledElement) {
897
+ return;
898
+ }
899
+ const { viewport } = enabledElement;
900
+ if (!(viewport instanceof _RenderingEngine_StackViewport__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)) {
901
+ throw new Error(`An image can only be fetched for a stack viewport and not for a viewport of type: ${viewport.type}`);
902
+ }
903
+ return viewport.getCornerstoneImage();
904
+ }
905
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (getImageLegacy);
906
+
907
+
908
+ /***/ }),
909
+
910
+ /***/ 25308:
911
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
912
+
913
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
914
+ /* harmony export */ A: () => (/* binding */ getMinMax)
915
+ /* harmony export */ });
916
+ function getMinMax(storedPixelData) {
917
+ let min = storedPixelData[0];
918
+ let max = storedPixelData[0];
919
+ let storedPixel;
920
+ const numPixels = storedPixelData.length;
921
+ for (let index = 1; index < numPixels; index++) {
922
+ storedPixel = storedPixelData[index];
923
+ min = Math.min(min, storedPixel);
924
+ max = Math.max(max, storedPixel);
925
+ }
926
+ return {
927
+ min,
928
+ max,
929
+ };
930
+ }
931
+
932
+
933
+ /***/ }),
934
+
935
+ /***/ 49398:
936
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
937
+
938
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
939
+ /* harmony export */ p: () => (/* binding */ getRandomSampleFromArray)
940
+ /* harmony export */ });
941
+ function getRandomSampleFromArray(array, size) {
942
+ const clonedArray = [...array];
943
+ if (size >= clonedArray.length) {
944
+ shuffleArray(clonedArray);
945
+ return clonedArray;
946
+ }
947
+ shuffleArray(clonedArray);
948
+ return clonedArray.slice(0, size);
949
+ }
950
+ function shuffleArray(array) {
951
+ for (let i = array.length - 1; i > 0; i--) {
952
+ const j = Math.floor(Math.random() * (i + 1));
953
+ [array[i], array[j]] = [array[j], array[i]];
954
+ }
955
+ }
956
+
957
+
958
+ /***/ }),
959
+
960
+ /***/ 10145:
961
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
962
+
963
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
964
+ /* harmony export */ A: () => (/* binding */ getRuntimeId)
965
+ /* harmony export */ });
966
+ const LAST_RUNTIME_ID = Symbol('LastRuntimeId');
967
+ const GLOBAL_CONTEXT = {};
968
+ const DEFAULT_MAX = 0xffffffff;
969
+ const DEFAULT_SEPARATOR = '-';
970
+ function getRuntimeId(context, separator, max) {
971
+ return getNextRuntimeId(context !== null && typeof context === 'object' ? context : GLOBAL_CONTEXT, LAST_RUNTIME_ID, (typeof max === 'number' && max > 0 ? max : DEFAULT_MAX) >>> 0).join(typeof separator === 'string' ? separator : DEFAULT_SEPARATOR);
972
+ }
973
+ function getNextRuntimeId(context, symbol, max) {
974
+ let idComponents = context[symbol];
975
+ if (!(idComponents instanceof Array)) {
976
+ idComponents = [0];
977
+ Object.defineProperty(context, symbol, { value: idComponents });
978
+ }
979
+ for (let carry = true, i = 0; carry && i < idComponents.length; ++i) {
980
+ let n = idComponents[i] | 0;
981
+ if (n < max) {
982
+ carry = false;
983
+ n = n + 1;
984
+ }
985
+ else {
986
+ n = 0;
987
+ if (i + 1 === idComponents.length) {
988
+ idComponents.push(0);
989
+ }
990
+ }
991
+ idComponents[i] = n;
992
+ }
993
+ return idComponents;
994
+ }
995
+
996
+
997
+ /***/ }),
998
+
999
+ /***/ 64448:
1000
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1001
+
1002
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1003
+ /* harmony export */ A: () => (/* binding */ getViewportImageCornersInWorld)
1004
+ /* harmony export */ });
1005
+ function getViewportImageCornersInWorld(viewport) {
1006
+ const { imageData, dimensions } = viewport.getImageData() || {};
1007
+ if (!imageData || !dimensions) {
1008
+ return [];
1009
+ }
1010
+ const { canvas } = viewport;
1011
+ const ratio = window.devicePixelRatio;
1012
+ const topLeftCanvas = [0, 0];
1013
+ const topRightCanvas = [canvas.width / ratio, 0];
1014
+ const bottomRightCanvas = [
1015
+ canvas.width / ratio,
1016
+ canvas.height / ratio,
1017
+ ];
1018
+ const bottomLeftCanvas = [0, canvas.height / ratio];
1019
+ const topLeftWorld = viewport.canvasToWorld(topLeftCanvas);
1020
+ const topRightWorld = viewport.canvasToWorld(topRightCanvas);
1021
+ const bottomRightWorld = viewport.canvasToWorld(bottomRightCanvas);
1022
+ const bottomLeftWorld = viewport.canvasToWorld(bottomLeftCanvas);
1023
+ const topLeftImage = imageData.worldToIndex(topLeftWorld);
1024
+ const topRightImage = imageData.worldToIndex(topRightWorld);
1025
+ const bottomRightImage = imageData.worldToIndex(bottomRightWorld);
1026
+ const bottomLeftImage = imageData.worldToIndex(bottomLeftWorld);
1027
+ return _getStackViewportImageCorners({
1028
+ dimensions,
1029
+ imageData,
1030
+ topLeftImage,
1031
+ topRightImage,
1032
+ bottomRightImage,
1033
+ bottomLeftImage,
1034
+ topLeftWorld,
1035
+ topRightWorld,
1036
+ bottomRightWorld,
1037
+ bottomLeftWorld,
1038
+ });
1039
+ }
1040
+ function _getStackViewportImageCorners({ dimensions, imageData, topLeftImage, topRightImage, bottomRightImage, bottomLeftImage, topLeftWorld, topRightWorld, bottomRightWorld, bottomLeftWorld, }) {
1041
+ const topLeftImageWorld = _isInBounds(topLeftImage, dimensions)
1042
+ ? topLeftWorld
1043
+ : imageData.indexToWorld([0, 0, 0]);
1044
+ const topRightImageWorld = _isInBounds(topRightImage, dimensions)
1045
+ ? topRightWorld
1046
+ : imageData.indexToWorld([dimensions[0] - 1, 0, 0]);
1047
+ const bottomRightImageWorld = _isInBounds(bottomRightImage, dimensions)
1048
+ ? bottomRightWorld
1049
+ : imageData.indexToWorld([
1050
+ dimensions[0] - 1,
1051
+ dimensions[1] - 1,
1052
+ 0,
1053
+ ]);
1054
+ const bottomLeftImageWorld = _isInBounds(bottomLeftImage, dimensions)
1055
+ ? bottomLeftWorld
1056
+ : imageData.indexToWorld([0, dimensions[1] - 1, 0]);
1057
+ return [
1058
+ topLeftImageWorld,
1059
+ topRightImageWorld,
1060
+ bottomLeftImageWorld,
1061
+ bottomRightImageWorld,
1062
+ ];
1063
+ }
1064
+ function _isInBounds(imageCoord, dimensions) {
1065
+ return (imageCoord[0] > 0 ||
1066
+ imageCoord[0] < dimensions[0] - 1 ||
1067
+ imageCoord[1] > 0 ||
1068
+ imageCoord[1] < dimensions[1] - 1 ||
1069
+ imageCoord[2] > 0 ||
1070
+ imageCoord[2] < dimensions[2] - 1);
1071
+ }
1072
+
1073
+
1074
+ /***/ }),
1075
+
1076
+ /***/ 9973:
1077
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1078
+
1079
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1080
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
1081
+ /* harmony export */ });
1082
+ /* harmony import */ var _RenderingEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(56706);
1083
+ /* harmony import */ var _cache_cache__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(49038);
1084
+
1085
+
1086
+ function getViewportImageIds(viewport) {
1087
+ if (viewport instanceof _RenderingEngine__WEBPACK_IMPORTED_MODULE_0__/* .VolumeViewport */ .PX) {
1088
+ const volume = _cache_cache__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Ay.getVolume(viewport.getVolumeId());
1089
+ return volume.imageIds;
1090
+ }
1091
+ else if (viewport.getImageIds) {
1092
+ return viewport.getImageIds();
1093
+ }
1094
+ }
1095
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (getViewportImageIds);
1096
+
1097
+
1098
+ /***/ }),
1099
+
1100
+ /***/ 30439:
1101
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1102
+
1103
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1104
+ /* harmony export */ p: () => (/* binding */ _getViewportModality)
1105
+ /* harmony export */ });
1106
+ function _getViewportModality(viewport, volumeId, getVolume) {
1107
+ if (!getVolume) {
1108
+ throw new Error('getVolume is required, use the utilities export instead ');
1109
+ }
1110
+ if (viewport.modality) {
1111
+ return viewport.modality;
1112
+ }
1113
+ if (viewport.setVolumes) {
1114
+ volumeId = volumeId ?? viewport.getVolumeId();
1115
+ if (!volumeId || !getVolume) {
1116
+ return;
1117
+ }
1118
+ const volume = getVolume(volumeId);
1119
+ return volume.metadata.Modality;
1120
+ }
1121
+ throw new Error('Invalid viewport type');
1122
+ }
1123
+
1124
+
1125
+
1126
+ /***/ }),
1127
+
1128
+ /***/ 13382:
1129
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1130
+
1131
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1132
+ /* harmony export */ A: () => (/* binding */ getViewportsWithImageURI)
1133
+ /* harmony export */ });
1134
+ /* harmony import */ var _RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(39536);
1135
+
1136
+ function getViewportsWithImageURI(imageURI) {
1137
+ const renderingEngines = (0,_RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_0__/* .getRenderingEngines */ .qO)();
1138
+ const viewports = [];
1139
+ renderingEngines.forEach((renderingEngine) => {
1140
+ const viewportsForRenderingEngine = renderingEngine.getViewports();
1141
+ viewportsForRenderingEngine.forEach((viewport) => {
1142
+ if (viewport.hasImageURI(imageURI)) {
1143
+ viewports.push(viewport);
1144
+ }
1145
+ });
1146
+ });
1147
+ return viewports;
1148
+ }
1149
+
1150
+
1151
+ /***/ }),
1152
+
1153
+ /***/ 93475:
1154
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1155
+
1156
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1157
+ /* harmony export */ A: () => (/* binding */ getVolumeDirectionVectors)
1158
+ /* harmony export */ });
1159
+ /* unused harmony export getVolumeDirectionVectors */
1160
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
1161
+ /* harmony import */ var _transformWorldToIndex__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(38669);
1162
+
1163
+
1164
+ function getVolumeDirectionVectors(imageData, camera) {
1165
+ const { viewUp, viewPlaneNormal } = camera;
1166
+ const ijkOrigin = (0,_transformWorldToIndex__WEBPACK_IMPORTED_MODULE_1__/* .transformWorldToIndexContinuous */ .p)(imageData, [0, 0, 0]);
1167
+ const worldVecColDir = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.negate */ .eR.negate(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), viewUp);
1168
+ const worldVecSliceDir = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.negate */ .eR.negate(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), viewPlaneNormal);
1169
+ const worldVecRowDir = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.cross */ .eR.cross(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), worldVecColDir, worldVecSliceDir);
1170
+ const ijkVecColDir = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.sub */ .eR.sub(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), (0,_transformWorldToIndex__WEBPACK_IMPORTED_MODULE_1__/* .transformWorldToIndexContinuous */ .p)(imageData, worldVecColDir), ijkOrigin);
1171
+ const ijkVecSliceDir = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.sub */ .eR.sub(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), (0,_transformWorldToIndex__WEBPACK_IMPORTED_MODULE_1__/* .transformWorldToIndexContinuous */ .p)(imageData, worldVecSliceDir), ijkOrigin);
1172
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.normalize */ .eR.normalize(ijkVecColDir, ijkVecColDir);
1173
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.normalize */ .eR.normalize(ijkVecSliceDir, ijkVecSliceDir);
1174
+ const ijkVecRowDir = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.cross */ .eR.cross(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create(), ijkVecColDir, ijkVecSliceDir);
1175
+ return {
1176
+ worldVecRowDir,
1177
+ worldVecColDir,
1178
+ worldVecSliceDir,
1179
+ ijkVecRowDir,
1180
+ ijkVecColDir,
1181
+ ijkVecSliceDir,
1182
+ };
1183
+ }
1184
+
1185
+
1186
+
1187
+ /***/ }),
1188
+
1189
+ /***/ 15388:
1190
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1191
+
1192
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1193
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
1194
+ /* harmony export */ });
1195
+ /* harmony import */ var _RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(39536);
1196
+
1197
+ function getVolumeViewportsContainingSameVolumes(targetViewport, renderingEngineId) {
1198
+ let renderingEngines;
1199
+ if (renderingEngineId) {
1200
+ renderingEngines = [(0,_RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_0__/* .getRenderingEngine */ .lD)(renderingEngineId)];
1201
+ }
1202
+ else {
1203
+ renderingEngines = (0,_RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_0__/* .getRenderingEngines */ .qO)();
1204
+ }
1205
+ const sameVolumesViewports = [];
1206
+ renderingEngines.forEach((renderingEngine) => {
1207
+ const targetActors = targetViewport.getActors();
1208
+ const viewports = renderingEngine.getVolumeViewports();
1209
+ for (const vp of viewports) {
1210
+ const vpActors = vp.getActors();
1211
+ if (vpActors.length !== targetActors.length) {
1212
+ continue;
1213
+ }
1214
+ const sameVolumes = targetActors.every(({ uid }) => vpActors.find((vpActor) => uid === vpActor.uid));
1215
+ if (sameVolumes) {
1216
+ sameVolumesViewports.push(vp);
1217
+ }
1218
+ }
1219
+ });
1220
+ return sameVolumesViewports;
1221
+ }
1222
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (getVolumeViewportsContainingSameVolumes);
1223
+
1224
+
1225
+ /***/ }),
1226
+
1227
+ /***/ 36527:
1228
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1229
+
1230
+ __webpack_require__.r(__webpack_exports__);
1231
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1232
+ /* harmony export */ DefaultHistoryMemo: () => (/* binding */ DefaultHistoryMemo),
1233
+ /* harmony export */ HistoryMemo: () => (/* binding */ HistoryMemo)
1234
+ /* harmony export */ });
1235
+ class HistoryMemo {
1236
+ constructor(label = 'Tools', size = 50) {
1237
+ this.position = -1;
1238
+ this.redoAvailable = 0;
1239
+ this.undoAvailable = 0;
1240
+ this.ring = new Array();
1241
+ this.label = label;
1242
+ this._size = size;
1243
+ }
1244
+ get size() {
1245
+ return this._size;
1246
+ }
1247
+ set size(newSize) {
1248
+ this.ring = new Array(newSize);
1249
+ this._size = newSize;
1250
+ this.position = -1;
1251
+ this.redoAvailable = 0;
1252
+ this.undoAvailable = 0;
1253
+ }
1254
+ undo(items = 1) {
1255
+ while (items > 0 && this.undoAvailable > 0) {
1256
+ const item = this.ring[this.position];
1257
+ item.restoreMemo(true);
1258
+ items--;
1259
+ this.redoAvailable++;
1260
+ this.undoAvailable--;
1261
+ this.position = (this.position - 1 + this.size) % this.size;
1262
+ }
1263
+ }
1264
+ redo(items = 1) {
1265
+ while (items > 0 && this.redoAvailable > 0) {
1266
+ const newPosition = (this.position + 1) % this.size;
1267
+ const item = this.ring[newPosition];
1268
+ item.restoreMemo(false);
1269
+ items--;
1270
+ this.position = newPosition;
1271
+ this.undoAvailable++;
1272
+ this.redoAvailable--;
1273
+ }
1274
+ }
1275
+ push(item) {
1276
+ if (!item) {
1277
+ return;
1278
+ }
1279
+ const memo = item.restoreMemo
1280
+ ? item
1281
+ : item.createMemo?.();
1282
+ if (!memo) {
1283
+ return;
1284
+ }
1285
+ this.redoAvailable = 0;
1286
+ if (this.undoAvailable < this._size) {
1287
+ this.undoAvailable++;
1288
+ }
1289
+ this.position = (this.position + 1) % this._size;
1290
+ this.ring[this.position] = memo;
1291
+ return memo;
1292
+ }
1293
+ }
1294
+ const DefaultHistoryMemo = new HistoryMemo();
1295
+
1296
+
1297
+
1298
+ /***/ }),
1299
+
1300
+ /***/ 79518:
1301
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1302
+
1303
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1304
+ /* harmony export */ A: () => (/* binding */ imageToWorldCoords)
1305
+ /* harmony export */ });
1306
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
1307
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(74876);
1308
+
1309
+
1310
+ function imageToWorldCoords(imageId, imageCoords) {
1311
+ const imagePlaneModule = (0,_metaData__WEBPACK_IMPORTED_MODULE_1__.get)('imagePlaneModule', imageId);
1312
+ if (!imagePlaneModule) {
1313
+ throw new Error(`No imagePlaneModule found for imageId: ${imageId}`);
1314
+ }
1315
+ const { columnCosines, rowCosines, imagePositionPatient: origin, } = imagePlaneModule;
1316
+ let { columnPixelSpacing, rowPixelSpacing } = imagePlaneModule;
1317
+ columnPixelSpacing ||= 1;
1318
+ rowPixelSpacing ||= 1;
1319
+ const imageCoordsInWorld = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create();
1320
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.scaleAndAdd */ .eR.scaleAndAdd(imageCoordsInWorld, origin, rowCosines, rowPixelSpacing * (imageCoords[0] - 0.5));
1321
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.scaleAndAdd */ .eR.scaleAndAdd(imageCoordsInWorld, imageCoordsInWorld, columnCosines, columnPixelSpacing * (imageCoords[1] - 0.5));
1322
+ return Array.from(imageCoordsInWorld);
1323
+ }
1324
+
1325
+
1326
+ /***/ }),
1327
+
1328
+ /***/ 57092:
1329
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1330
+
1331
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1332
+ /* harmony export */ A: () => (/* binding */ indexWithinDimensions)
1333
+ /* harmony export */ });
1334
+ function indexWithinDimensions(index, dimensions) {
1335
+ if (index[0] < 0 ||
1336
+ index[0] >= dimensions[0] ||
1337
+ index[1] < 0 ||
1338
+ index[1] >= dimensions[1] ||
1339
+ index[2] < 0 ||
1340
+ index[2] >= dimensions[2]) {
1341
+ return false;
1342
+ }
1343
+ return true;
1344
+ }
1345
+
1346
+
1347
+ /***/ }),
1348
+
1349
+ /***/ 74638:
1350
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1351
+
1352
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1353
+ /* harmony export */ Ay: () => (/* binding */ isEqual),
1354
+ /* harmony export */ Ph: () => (/* binding */ isEqualAbs),
1355
+ /* harmony export */ WC: () => (/* binding */ isEqualNegative),
1356
+ /* harmony export */ n4: () => (/* binding */ isEqual)
1357
+ /* harmony export */ });
1358
+ function areNumbersEqualWithTolerance(num1, num2, tolerance) {
1359
+ return Math.abs(num1 - num2) <= tolerance;
1360
+ }
1361
+ function areArraysEqual(arr1, arr2, tolerance = 1e-5) {
1362
+ if (arr1.length !== arr2.length) {
1363
+ return false;
1364
+ }
1365
+ for (let i = 0; i < arr1.length; i++) {
1366
+ if (!areNumbersEqualWithTolerance(arr1[i], arr2[i], tolerance)) {
1367
+ return false;
1368
+ }
1369
+ }
1370
+ return true;
1371
+ }
1372
+ function isNumberType(value) {
1373
+ return typeof value === 'number';
1374
+ }
1375
+ function isNumberArrayLike(value) {
1376
+ return (value &&
1377
+ typeof value === 'object' &&
1378
+ 'length' in value &&
1379
+ typeof value.length === 'number' &&
1380
+ value.length > 0 &&
1381
+ typeof value[0] === 'number');
1382
+ }
1383
+ function isEqual(v1, v2, tolerance = 1e-5) {
1384
+ if (typeof v1 !== typeof v2 || v1 === null || v2 === null) {
1385
+ return false;
1386
+ }
1387
+ if (isNumberType(v1) && isNumberType(v2)) {
1388
+ return areNumbersEqualWithTolerance(v1, v2, tolerance);
1389
+ }
1390
+ if (isNumberArrayLike(v1) && isNumberArrayLike(v2)) {
1391
+ return areArraysEqual(v1, v2, tolerance);
1392
+ }
1393
+ return false;
1394
+ }
1395
+ const negative = (v) => typeof v === 'number' ? -v : v?.map ? v.map(negative) : !v;
1396
+ const abs = (v) => typeof v === 'number' ? Math.abs(v) : v?.map ? v.map(abs) : v;
1397
+ const isEqualNegative = (v1, v2, tolerance = undefined) => isEqual(v1, negative(v2), tolerance);
1398
+ const isEqualAbs = (v1, v2, tolerance = undefined) => isEqual(abs(v1), abs(v2), tolerance);
1399
+
1400
+
1401
+
1402
+ /***/ }),
1403
+
1404
+ /***/ 37657:
1405
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1406
+
1407
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1408
+ /* harmony export */ A: () => (/* binding */ isOpposite)
1409
+ /* harmony export */ });
1410
+ function isOpposite(v1, v2, tolerance = 1e-5) {
1411
+ return (Math.abs(v1[0] + v2[0]) < tolerance &&
1412
+ Math.abs(v1[1] + v2[1]) < tolerance &&
1413
+ Math.abs(v1[2] + v2[2]) < tolerance);
1414
+ }
1415
+
1416
+
1417
+ /***/ }),
1418
+
1419
+ /***/ 55947:
1420
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1421
+
1422
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1423
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
1424
+ /* harmony export */ });
1425
+ const isPTPrescaledWithSUV = (image) => {
1426
+ return image.preScale.scaled && image.preScale.scalingParameters.suvbw;
1427
+ };
1428
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (isPTPrescaledWithSUV);
1429
+
1430
+
1431
+ /***/ }),
1432
+
1433
+ /***/ 77854:
1434
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1435
+
1436
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1437
+ /* harmony export */ p: () => (/* binding */ isValidVolume)
1438
+ /* harmony export */ });
1439
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(74876);
1440
+ /* harmony import */ var _isEqual__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(74638);
1441
+
1442
+
1443
+ function isValidVolume(imageIds) {
1444
+ const imageId0 = imageIds[0];
1445
+ const { modality, seriesInstanceUID } = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('generalSeriesModule', imageId0);
1446
+ const { imageOrientationPatient, pixelSpacing, frameOfReferenceUID, columns, rows, } = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('imagePlaneModule', imageId0);
1447
+ const baseMetadata = {
1448
+ modality,
1449
+ imageOrientationPatient,
1450
+ pixelSpacing,
1451
+ frameOfReferenceUID,
1452
+ columns,
1453
+ rows,
1454
+ seriesInstanceUID,
1455
+ };
1456
+ const validVolume = imageIds.every((imageId) => {
1457
+ const { modality, seriesInstanceUID } = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('generalSeriesModule', imageId);
1458
+ const { imageOrientationPatient, pixelSpacing, columns, rows } = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('imagePlaneModule', imageId);
1459
+ return (seriesInstanceUID === baseMetadata.seriesInstanceUID &&
1460
+ modality === baseMetadata.modality &&
1461
+ columns === baseMetadata.columns &&
1462
+ rows === baseMetadata.rows &&
1463
+ (0,_isEqual__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Ay)(imageOrientationPatient, baseMetadata.imageOrientationPatient) &&
1464
+ (0,_isEqual__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .Ay)(pixelSpacing, baseMetadata.pixelSpacing));
1465
+ });
1466
+ return validVolume;
1467
+ }
1468
+
1469
+
1470
+
1471
+ /***/ }),
1472
+
1473
+ /***/ 79697:
1474
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1475
+
1476
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1477
+ /* harmony export */ A: () => (/* binding */ isVideoTransferSyntax)
1478
+ /* harmony export */ });
1479
+ /* unused harmony export videoUIDs */
1480
+ const videoUIDs = new Set([
1481
+ '1.2.840.10008.1.2.4.100',
1482
+ '1.2.840.10008.1.2.4.100.1',
1483
+ '1.2.840.10008.1.2.4.101',
1484
+ '1.2.840.10008.1.2.4.101.1',
1485
+ '1.2.840.10008.1.2.4.102',
1486
+ '1.2.840.10008.1.2.4.102.1',
1487
+ '1.2.840.10008.1.2.4.103',
1488
+ '1.2.840.10008.1.2.4.103.1',
1489
+ '1.2.840.10008.1.2.4.104',
1490
+ '1.2.840.10008.1.2.4.104.1',
1491
+ '1.2.840.10008.1.2.4.105',
1492
+ '1.2.840.10008.1.2.4.105.1',
1493
+ '1.2.840.10008.1.2.4.106',
1494
+ '1.2.840.10008.1.2.4.106.1',
1495
+ '1.2.840.10008.1.2.4.107',
1496
+ '1.2.840.10008.1.2.4.108',
1497
+ ]);
1498
+ function isVideoTransferSyntax(uidOrUids) {
1499
+ if (!uidOrUids) {
1500
+ return false;
1501
+ }
1502
+ const uids = Array.isArray(uidOrUids) ? uidOrUids : [uidOrUids];
1503
+ return uids.find((uid) => videoUIDs.has(uid));
1504
+ }
1505
+
1506
+
1507
+ /***/ }),
1508
+
1509
+ /***/ 86391:
1510
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1511
+
1512
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1513
+ /* harmony export */ e: () => (/* binding */ jumpToSlice)
1514
+ /* harmony export */ });
1515
+ /* harmony import */ var _clip__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(25534);
1516
+ /* harmony import */ var _scroll__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(36277);
1517
+ /* harmony import */ var _getEnabledElement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(86846);
1518
+ /* harmony import */ var _RenderingEngine_StackViewport__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(58165);
1519
+
1520
+
1521
+
1522
+
1523
+ async function jumpToSlice(element, options = {}) {
1524
+ const { imageIndex, debounceLoading, volumeId } = options;
1525
+ const enabledElement = (0,_getEnabledElement__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .Ay)(element);
1526
+ if (!enabledElement) {
1527
+ throw new Error('Element has been disabled');
1528
+ }
1529
+ const { viewport } = enabledElement;
1530
+ const { imageIndex: currentImageIndex, numberOfSlices } = _getImageSliceData(viewport, debounceLoading);
1531
+ const imageIndexToJump = _getImageIndexToJump(numberOfSlices, imageIndex);
1532
+ const delta = imageIndexToJump - currentImageIndex;
1533
+ (0,_scroll__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)(viewport, { delta, debounceLoading, volumeId });
1534
+ }
1535
+ function _getImageSliceData(viewport, debounceLoading) {
1536
+ if (viewport instanceof _RenderingEngine_StackViewport__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A) {
1537
+ return {
1538
+ numberOfSlices: viewport.getImageIds().length,
1539
+ imageIndex: debounceLoading
1540
+ ? viewport.getTargetImageIdIndex()
1541
+ : viewport.getCurrentImageIdIndex(),
1542
+ };
1543
+ }
1544
+ return {
1545
+ numberOfSlices: viewport.getNumberOfSlices(),
1546
+ imageIndex: viewport.getSliceIndex(),
1547
+ };
1548
+ }
1549
+ function _getImageIndexToJump(numberOfSlices, imageIndex) {
1550
+ const lastSliceIndex = numberOfSlices - 1;
1551
+ return (0,_clip__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Ay)(imageIndex, 0, lastSliceIndex);
1552
+ }
1553
+
1554
+
1555
+
1556
+ /***/ }),
1557
+
1558
+ /***/ 24662:
1559
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1560
+
1561
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1562
+ /* harmony export */ A: () => (/* binding */ loadImageToCanvas)
1563
+ /* harmony export */ });
1564
+ /* harmony import */ var _loaders_imageLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(80068);
1565
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(74876);
1566
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(31749);
1567
+ /* harmony import */ var _requestPool_imageLoadPoolManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(51159);
1568
+ /* harmony import */ var _renderToCanvasGPU__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3667);
1569
+ /* harmony import */ var _renderToCanvasCPU__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(38583);
1570
+ /* harmony import */ var _init__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(59693);
1571
+ /* harmony import */ var _cache_cache__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(49038);
1572
+
1573
+
1574
+
1575
+
1576
+
1577
+
1578
+
1579
+
1580
+ function loadImageToCanvas(options) {
1581
+ const { canvas, imageId, viewReference, requestType = _enums__WEBPACK_IMPORTED_MODULE_2__.RequestType.Thumbnail, priority = -5, renderingEngineId = '_thumbnails', useCPURendering = false, thumbnail = false, imageAspect = false, viewportOptions: baseViewportOptions, } = options;
1582
+ const volumeId = viewReference?.volumeId;
1583
+ const isVolume = volumeId && !imageId;
1584
+ const viewportOptions = viewReference && baseViewportOptions
1585
+ ? { ...baseViewportOptions, viewReference }
1586
+ : baseViewportOptions;
1587
+ const renderFn = useCPURendering ? _renderToCanvasCPU__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .A : _renderToCanvasGPU__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A;
1588
+ return new Promise((resolve, reject) => {
1589
+ function successCallback(imageOrVolume, imageId) {
1590
+ const { modality } = _metaData__WEBPACK_IMPORTED_MODULE_1__.get('generalSeriesModule', imageId) || {};
1591
+ const image = !isVolume && imageOrVolume;
1592
+ const volume = isVolume && imageOrVolume;
1593
+ if (image) {
1594
+ image.isPreScaled = image.isPreScaled || image.preScale?.scaled;
1595
+ }
1596
+ if (thumbnail) {
1597
+ canvas.height = 256;
1598
+ canvas.width = 256;
1599
+ }
1600
+ if (imageAspect && image) {
1601
+ canvas.width = image && (canvas.height * image.width) / image.height;
1602
+ }
1603
+ canvas.style.width = `${canvas.width / devicePixelRatio}px`;
1604
+ canvas.style.height = `${canvas.height / devicePixelRatio}px`;
1605
+ if (volume && useCPURendering) {
1606
+ reject(new Error('CPU rendering of volume not supported'));
1607
+ }
1608
+ renderFn(canvas, imageOrVolume, modality, renderingEngineId, viewportOptions).then(resolve);
1609
+ }
1610
+ function errorCallback(error, imageId) {
1611
+ console.error(error, imageId);
1612
+ reject(error);
1613
+ }
1614
+ function sendRequest(imageId, imageIdIndex, options) {
1615
+ return (0,_loaders_imageLoader__WEBPACK_IMPORTED_MODULE_0__.loadAndCacheImage)(imageId, options).then((image) => {
1616
+ successCallback.call(this, image, imageId);
1617
+ }, (error) => {
1618
+ errorCallback.call(this, error, imageId);
1619
+ });
1620
+ }
1621
+ const options = {
1622
+ useRGBA: !!useCPURendering,
1623
+ requestType,
1624
+ };
1625
+ if (volumeId) {
1626
+ const volume = _cache_cache__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .Ay.getVolume(volumeId);
1627
+ if (!volume) {
1628
+ reject(new Error(`Volume id ${volumeId} not found in cache`));
1629
+ }
1630
+ const useImageId = volume.imageIds[0];
1631
+ successCallback(volume, useImageId);
1632
+ }
1633
+ else {
1634
+ _requestPool_imageLoadPoolManager__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A.addRequest(sendRequest.bind(null, imageId, null, options), requestType, { imageId }, priority);
1635
+ }
1636
+ });
1637
+ }
1638
+
1639
+
1640
+ /***/ }),
1641
+
1642
+ /***/ 52268:
1643
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1644
+
1645
+ __webpack_require__.r(__webpack_exports__);
1646
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1647
+ /* harmony export */ linePlaneIntersection: () => (/* binding */ linePlaneIntersection),
1648
+ /* harmony export */ planeDistanceToPoint: () => (/* binding */ planeDistanceToPoint),
1649
+ /* harmony export */ planeEquation: () => (/* binding */ planeEquation),
1650
+ /* harmony export */ threePlaneIntersection: () => (/* binding */ threePlaneIntersection)
1651
+ /* harmony export */ });
1652
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
1653
+
1654
+ function linePlaneIntersection(p0, p1, plane) {
1655
+ const [x0, y0, z0] = p0;
1656
+ const [x1, y1, z1] = p1;
1657
+ const [A, B, C, D] = plane;
1658
+ const a = x1 - x0;
1659
+ const b = y1 - y0;
1660
+ const c = z1 - z0;
1661
+ const t = (-1 * (A * x0 + B * y0 + C * z0 - D)) / (A * a + B * b + C * c);
1662
+ const X = a * t + x0;
1663
+ const Y = b * t + y0;
1664
+ const Z = c * t + z0;
1665
+ return [X, Y, Z];
1666
+ }
1667
+ function planeEquation(normal, point, normalized = false) {
1668
+ const [A, B, C] = normal;
1669
+ const D = A * point[0] + B * point[1] + C * point[2];
1670
+ if (normalized) {
1671
+ const length = Math.sqrt(A * A + B * B + C * C);
1672
+ return [A / length, B / length, C / length, D / length];
1673
+ }
1674
+ return [A, B, C, D];
1675
+ }
1676
+ function threePlaneIntersection(firstPlane, secondPlane, thirdPlane) {
1677
+ const [A1, B1, C1, D1] = firstPlane;
1678
+ const [A2, B2, C2, D2] = secondPlane;
1679
+ const [A3, B3, C3, D3] = thirdPlane;
1680
+ const m0 = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat3.fromValues */ .w0.fromValues(A1, A2, A3, B1, B2, B3, C1, C2, C3);
1681
+ const m1 = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat3.fromValues */ .w0.fromValues(D1, D2, D3, B1, B2, B3, C1, C2, C3);
1682
+ const m2 = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat3.fromValues */ .w0.fromValues(A1, A2, A3, D1, D2, D3, C1, C2, C3);
1683
+ const m3 = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat3.fromValues */ .w0.fromValues(A1, A2, A3, B1, B2, B3, D1, D2, D3);
1684
+ const x = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat3.determinant */ .w0.determinant(m1) / gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat3.determinant */ .w0.determinant(m0);
1685
+ const y = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat3.determinant */ .w0.determinant(m2) / gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat3.determinant */ .w0.determinant(m0);
1686
+ const z = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat3.determinant */ .w0.determinant(m3) / gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat3.determinant */ .w0.determinant(m0);
1687
+ return [x, y, z];
1688
+ }
1689
+ function planeDistanceToPoint(plane, point, signed = false) {
1690
+ const [A, B, C, D] = plane;
1691
+ const [x, y, z] = point;
1692
+ const numerator = A * x + B * y + C * z - D;
1693
+ const distance = Math.abs(numerator) / Math.sqrt(A * A + B * B + C * C);
1694
+ const sign = signed ? Math.sign(numerator) : 1;
1695
+ return sign * distance;
1696
+ }
1697
+
1698
+
1699
+
1700
+ /***/ }),
1701
+
1702
+ /***/ 38583:
1703
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1704
+
1705
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1706
+ /* harmony export */ A: () => (/* binding */ renderToCanvasCPU)
1707
+ /* harmony export */ });
1708
+ /* harmony import */ var _RenderingEngine_helpers_cpuFallback_rendering_getDefaultViewport__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(36931);
1709
+ /* harmony import */ var _RenderingEngine_helpers_cpuFallback_rendering_calculateTransform__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7808);
1710
+ /* harmony import */ var _RenderingEngine_helpers_cpuFallback_drawImageSync__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5057);
1711
+
1712
+
1713
+
1714
+ function renderToCanvasCPU(canvas, imageOrVolume, modality, _renderingEngineId, _viewportOptions) {
1715
+ const volume = imageOrVolume;
1716
+ if (volume.volumeId) {
1717
+ throw new Error('Unsupported volume rendering for CPU');
1718
+ }
1719
+ const image = imageOrVolume;
1720
+ const viewport = (0,_RenderingEngine_helpers_cpuFallback_rendering_getDefaultViewport__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(canvas, image, modality);
1721
+ const enabledElement = {
1722
+ canvas,
1723
+ viewport,
1724
+ image,
1725
+ renderingTools: {},
1726
+ };
1727
+ enabledElement.transform = (0,_RenderingEngine_helpers_cpuFallback_rendering_calculateTransform__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)(enabledElement);
1728
+ const invalidated = true;
1729
+ return new Promise((resolve, reject) => {
1730
+ (0,_RenderingEngine_helpers_cpuFallback_drawImageSync__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A)(enabledElement, invalidated);
1731
+ resolve(null);
1732
+ });
1733
+ }
1734
+
1735
+
1736
+ /***/ }),
1737
+
1738
+ /***/ 3667:
1739
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1740
+
1741
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1742
+ /* harmony export */ A: () => (/* binding */ renderToCanvasGPU)
1743
+ /* harmony export */ });
1744
+ /* harmony import */ var _RenderingEngine_helpers_getOrCreateCanvas__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(30135);
1745
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(31749);
1746
+ /* harmony import */ var _RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(39536);
1747
+ /* harmony import */ var _RenderingEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(56706);
1748
+ /* harmony import */ var _isPTPrescaledWithSUV__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(55947);
1749
+
1750
+
1751
+
1752
+
1753
+
1754
+ function renderToCanvasGPU(canvas, imageOrVolume, modality = undefined, renderingEngineId = '_thumbnails', viewportOptions = {
1755
+ displayArea: { imageArea: [1, 1] },
1756
+ }) {
1757
+ if (!canvas || !(canvas instanceof HTMLCanvasElement)) {
1758
+ throw new Error('canvas element is required');
1759
+ }
1760
+ const isVolume = !imageOrVolume.imageId;
1761
+ const image = !isVolume && imageOrVolume;
1762
+ const volume = isVolume && imageOrVolume;
1763
+ const imageIdToPrint = image.imageId || volume.volumeId;
1764
+ const viewportId = `renderGPUViewport-${imageIdToPrint}`;
1765
+ const element = document.createElement('div');
1766
+ const devicePixelRatio = window.devicePixelRatio || 1;
1767
+ if (!viewportOptions.displayArea) {
1768
+ viewportOptions.displayArea = { imageArea: [1, 1] };
1769
+ }
1770
+ const originalWidth = canvas.width;
1771
+ const originalHeight = canvas.height;
1772
+ element.style.width = `${originalWidth / devicePixelRatio + _RenderingEngine_helpers_getOrCreateCanvas__WEBPACK_IMPORTED_MODULE_0__/* .EPSILON */ .p8}px`;
1773
+ element.style.height = `${originalHeight / devicePixelRatio + _RenderingEngine_helpers_getOrCreateCanvas__WEBPACK_IMPORTED_MODULE_0__/* .EPSILON */ .p8}px`;
1774
+ element.style.visibility = 'hidden';
1775
+ element.style.position = 'absolute';
1776
+ document.body.appendChild(element);
1777
+ const uniqueId = viewportId.split(':').join('-');
1778
+ element.setAttribute('viewport-id-for-remove', uniqueId);
1779
+ const temporaryCanvas = (0,_RenderingEngine_helpers_getOrCreateCanvas__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Ay)(element);
1780
+ const renderingEngine = (0,_RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_2__/* .getRenderingEngine */ .lD)(renderingEngineId) ||
1781
+ new _RenderingEngine__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .Ay(renderingEngineId);
1782
+ let viewport = renderingEngine.getViewport(viewportId);
1783
+ if (!viewport) {
1784
+ const viewportInput = {
1785
+ viewportId,
1786
+ type: isVolume ? _enums__WEBPACK_IMPORTED_MODULE_1__.ViewportType.ORTHOGRAPHIC : _enums__WEBPACK_IMPORTED_MODULE_1__.ViewportType.STACK,
1787
+ element,
1788
+ defaultOptions: {
1789
+ ...viewportOptions,
1790
+ suppressEvents: true,
1791
+ },
1792
+ };
1793
+ renderingEngine.enableElement(viewportInput);
1794
+ viewport = renderingEngine.getViewport(viewportId);
1795
+ }
1796
+ return new Promise((resolve) => {
1797
+ let elementRendered = false;
1798
+ let { viewReference } = viewportOptions;
1799
+ const onImageRendered = (eventDetail) => {
1800
+ if (elementRendered) {
1801
+ return;
1802
+ }
1803
+ if (viewReference) {
1804
+ const useViewRef = viewReference;
1805
+ viewReference = null;
1806
+ viewport.setViewReference(useViewRef);
1807
+ viewport.render();
1808
+ return;
1809
+ }
1810
+ const context = canvas.getContext('2d');
1811
+ context.drawImage(temporaryCanvas, 0, 0, temporaryCanvas.width, temporaryCanvas.height, 0, 0, canvas.width, canvas.height);
1812
+ const origin = viewport.canvasToWorld([0, 0]);
1813
+ const topRight = viewport.canvasToWorld([
1814
+ temporaryCanvas.width / devicePixelRatio,
1815
+ 0,
1816
+ ]);
1817
+ const bottomLeft = viewport.canvasToWorld([
1818
+ 0,
1819
+ temporaryCanvas.height / devicePixelRatio,
1820
+ ]);
1821
+ const thicknessMm = 1;
1822
+ elementRendered = true;
1823
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_1__.Events.IMAGE_RENDERED, onImageRendered);
1824
+ setTimeout(() => {
1825
+ renderingEngine.disableElement(viewportId);
1826
+ const elements = document.querySelectorAll(`[viewport-id-for-remove="${uniqueId}"]`);
1827
+ elements.forEach((element) => {
1828
+ element.remove();
1829
+ });
1830
+ }, 0);
1831
+ resolve({
1832
+ origin,
1833
+ bottomLeft,
1834
+ topRight,
1835
+ thicknessMm,
1836
+ });
1837
+ };
1838
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_1__.Events.IMAGE_RENDERED, onImageRendered);
1839
+ if (isVolume) {
1840
+ viewport.setVolumes([volume], false, true);
1841
+ }
1842
+ else {
1843
+ viewport.renderImageObject(imageOrVolume);
1844
+ }
1845
+ viewport.resetCamera();
1846
+ if (modality === 'PT' && !(0,_isPTPrescaledWithSUV__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A)(image)) {
1847
+ viewport.setProperties({
1848
+ voiRange: {
1849
+ lower: image.minPixelValue,
1850
+ upper: image.maxPixelValue,
1851
+ },
1852
+ });
1853
+ }
1854
+ viewport.render();
1855
+ });
1856
+ }
1857
+
1858
+
1859
+ /***/ }),
1860
+
1861
+ /***/ 1587:
1862
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1863
+
1864
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1865
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__),
1866
+ /* harmony export */ C: () => (/* binding */ roundToPrecision)
1867
+ /* harmony export */ });
1868
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19325);
1869
+
1870
+ function roundNumber(value, precision = 2) {
1871
+ if (Array.isArray(value)) {
1872
+ return value.map((v) => roundNumber(v, precision)).join(', ');
1873
+ }
1874
+ if (value === undefined || value === null || value === '') {
1875
+ return 'NaN';
1876
+ }
1877
+ value = Number(value);
1878
+ const absValue = Math.abs(value);
1879
+ if (absValue < 0.0001) {
1880
+ return `${value}`;
1881
+ }
1882
+ const fixedPrecision = absValue >= 100
1883
+ ? precision - 2
1884
+ : absValue >= 10
1885
+ ? precision - 1
1886
+ : absValue >= 1
1887
+ ? precision
1888
+ : absValue >= 0.1
1889
+ ? precision + 1
1890
+ : absValue >= 0.01
1891
+ ? precision + 2
1892
+ : absValue >= 0.001
1893
+ ? precision + 3
1894
+ : precision + 4;
1895
+ return value.toFixed(fixedPrecision);
1896
+ }
1897
+ function roundToPrecision(value) {
1898
+ return Math.round(value / _constants__WEBPACK_IMPORTED_MODULE_0__.EPSILON) * _constants__WEBPACK_IMPORTED_MODULE_0__.EPSILON;
1899
+ }
1900
+
1901
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (roundNumber);
1902
+
1903
+
1904
+ /***/ }),
1905
+
1906
+ /***/ 44335:
1907
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1908
+
1909
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1910
+ /* harmony export */ A: () => (/* binding */ scaleArray)
1911
+ /* harmony export */ });
1912
+ function scaleArray(array, scalingParameters) {
1913
+ const arrayLength = array.length;
1914
+ const { rescaleSlope, rescaleIntercept, suvbw } = scalingParameters;
1915
+ if (scalingParameters.modality === 'PT' && typeof suvbw === 'number') {
1916
+ for (let i = 0; i < arrayLength; i++) {
1917
+ array[i] = suvbw * (array[i] * rescaleSlope + rescaleIntercept);
1918
+ }
1919
+ }
1920
+ else {
1921
+ for (let i = 0; i < arrayLength; i++) {
1922
+ array[i] = array[i] * rescaleSlope + rescaleIntercept;
1923
+ }
1924
+ }
1925
+ return array;
1926
+ }
1927
+
1928
+
1929
+ /***/ }),
1930
+
1931
+ /***/ 44134:
1932
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1933
+
1934
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1935
+ /* harmony export */ A: () => (/* binding */ scaleRGBTransferFunction)
1936
+ /* harmony export */ });
1937
+ function scaleRGBTransferFunction(rgbTransferFunction, scalingFactor) {
1938
+ const size = rgbTransferFunction.getSize();
1939
+ for (let index = 0; index < size; index++) {
1940
+ const nodeValue1 = [];
1941
+ rgbTransferFunction.getNodeValue(index, nodeValue1);
1942
+ nodeValue1[1] = nodeValue1[1] * scalingFactor;
1943
+ nodeValue1[2] = nodeValue1[2] * scalingFactor;
1944
+ nodeValue1[3] = nodeValue1[3] * scalingFactor;
1945
+ rgbTransferFunction.setNodeValue(index, nodeValue1);
1946
+ }
1947
+ }
1948
+
1949
+
1950
+ /***/ }),
1951
+
1952
+ /***/ 36277:
1953
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1954
+
1955
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1956
+ /* harmony export */ A: () => (/* binding */ scroll)
1957
+ /* harmony export */ });
1958
+ /* unused harmony export scrollVolume */
1959
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(31749);
1960
+ /* harmony import */ var _RenderingEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(56706);
1961
+ /* harmony import */ var _getVolumeViewportScrollInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(61375);
1962
+ /* harmony import */ var _snapFocalPointToSlice__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(80500);
1963
+ /* harmony import */ var _getEnabledElement__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(86846);
1964
+ /* harmony import */ var _triggerEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(69372);
1965
+ /* harmony import */ var _eventTarget__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(10364);
1966
+
1967
+
1968
+
1969
+
1970
+
1971
+
1972
+
1973
+ function scroll(viewport, options) {
1974
+ const enabledElement = (0,_getEnabledElement__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Ay)(viewport.element);
1975
+ if (!enabledElement) {
1976
+ throw new Error('Scroll::Viewport is not enabled (it might be disabled)');
1977
+ }
1978
+ if (viewport instanceof _RenderingEngine__WEBPACK_IMPORTED_MODULE_1__/* .StackViewport */ .hS &&
1979
+ viewport.getImageIds().length === 0) {
1980
+ throw new Error('Scroll::Stack Viewport has no images');
1981
+ }
1982
+ const { volumeId, delta, scrollSlabs } = options;
1983
+ if (viewport instanceof _RenderingEngine__WEBPACK_IMPORTED_MODULE_1__/* .VolumeViewport */ .PX) {
1984
+ scrollVolume(viewport, volumeId, delta, scrollSlabs);
1985
+ }
1986
+ else {
1987
+ const imageIdIndex = viewport.getCurrentImageIdIndex();
1988
+ if (imageIdIndex + delta >
1989
+ viewport.getImageIds().length - 1 ||
1990
+ imageIdIndex + delta < 0) {
1991
+ const eventData = {
1992
+ imageIdIndex,
1993
+ direction: delta,
1994
+ };
1995
+ (0,_triggerEvent__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .A)(_eventTarget__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .A, _enums__WEBPACK_IMPORTED_MODULE_0__.Events.STACK_SCROLL_OUT_OF_BOUNDS, eventData);
1996
+ }
1997
+ viewport.scroll(delta, options.debounceLoading, options.loop);
1998
+ }
1999
+ }
2000
+ function scrollVolume(viewport, volumeId, delta, scrollSlabs = false) {
2001
+ const useSlabThickness = scrollSlabs;
2002
+ const { numScrollSteps, currentStepIndex, sliceRangeInfo } = (0,_getVolumeViewportScrollInfo__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A)(viewport, volumeId, useSlabThickness);
2003
+ if (!sliceRangeInfo) {
2004
+ return;
2005
+ }
2006
+ const { sliceRange, spacingInNormalDirection, camera } = sliceRangeInfo;
2007
+ const { focalPoint, viewPlaneNormal, position } = camera;
2008
+ const { newFocalPoint, newPosition } = (0,_snapFocalPointToSlice__WEBPACK_IMPORTED_MODULE_3__/* ["default"] */ .A)(focalPoint, position, sliceRange, viewPlaneNormal, spacingInNormalDirection, delta);
2009
+ viewport.setCamera({
2010
+ focalPoint: newFocalPoint,
2011
+ position: newPosition,
2012
+ });
2013
+ viewport.render();
2014
+ const desiredStepIndex = currentStepIndex + delta;
2015
+ const VolumeScrollEventDetail = {
2016
+ volumeId,
2017
+ viewport,
2018
+ delta,
2019
+ desiredStepIndex,
2020
+ currentStepIndex,
2021
+ numScrollSteps,
2022
+ currentImageId: viewport.getCurrentImageId(),
2023
+ };
2024
+ if ((desiredStepIndex > numScrollSteps || desiredStepIndex < 0) &&
2025
+ viewport.getCurrentImageId()) {
2026
+ (0,_triggerEvent__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .A)(_eventTarget__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .A, _enums__WEBPACK_IMPORTED_MODULE_0__.Events.VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS, VolumeScrollEventDetail);
2027
+ }
2028
+ else {
2029
+ (0,_triggerEvent__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .A)(_eventTarget__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .A, _enums__WEBPACK_IMPORTED_MODULE_0__.Events.VOLUME_VIEWPORT_SCROLL, VolumeScrollEventDetail);
2030
+ }
2031
+ }
2032
+
2033
+
2034
+ /***/ }),
2035
+
2036
+ /***/ 40239:
2037
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2038
+
2039
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2040
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
2041
+ /* harmony export */ });
2042
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
2043
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(74876);
2044
+
2045
+
2046
+ const state = {};
2047
+ const spatialRegistrationMetadataProvider = {
2048
+ add: (query, payload) => {
2049
+ const [viewportId1, viewportId2] = query;
2050
+ const entryId = `${viewportId1}_${viewportId2}`;
2051
+ if (!state[entryId]) {
2052
+ state[entryId] = {};
2053
+ }
2054
+ state[entryId] = payload;
2055
+ },
2056
+ get: (type, viewportId1, viewportId2) => {
2057
+ if (type !== 'spatialRegistrationModule') {
2058
+ return;
2059
+ }
2060
+ const entryId = `${viewportId1}_${viewportId2}`;
2061
+ if (state[entryId]) {
2062
+ return state[entryId];
2063
+ }
2064
+ const entryIdReverse = `${viewportId2}_${viewportId1}`;
2065
+ if (state[entryIdReverse]) {
2066
+ return gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat4.invert */ .pB.invert(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .mat4.create */ .pB.create(), state[entryIdReverse]);
2067
+ }
2068
+ },
2069
+ };
2070
+ (0,_metaData__WEBPACK_IMPORTED_MODULE_1__.addProvider)(spatialRegistrationMetadataProvider.get.bind(spatialRegistrationMetadataProvider));
2071
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (spatialRegistrationMetadataProvider);
2072
+
2073
+
2074
+ /***/ }),
2075
+
2076
+ /***/ 31215:
2077
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2078
+
2079
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2080
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
2081
+ /* harmony export */ });
2082
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(74876);
2083
+
2084
+ const groupBy = (array, key) => {
2085
+ return array.reduce((rv, x) => {
2086
+ (rv[x[key]] = rv[x[key]] || []).push(x);
2087
+ return rv;
2088
+ }, {});
2089
+ };
2090
+ function getIPPGroups(imageIds) {
2091
+ const ippMetadata = imageIds.map((imageId) => {
2092
+ const { imagePositionPatient } = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('imagePlaneModule', imageId) || {};
2093
+ return { imageId, imagePositionPatient };
2094
+ });
2095
+ if (!ippMetadata.every((item) => item.imagePositionPatient)) {
2096
+ return null;
2097
+ }
2098
+ const positionGroups = groupBy(ippMetadata, 'imagePositionPatient');
2099
+ const positions = Object.keys(positionGroups);
2100
+ const frame_count = positionGroups[positions[0]].length;
2101
+ if (frame_count === 1) {
2102
+ return null;
2103
+ }
2104
+ const frame_count_equal = positions.every((k) => positionGroups[k].length === frame_count);
2105
+ if (!frame_count_equal) {
2106
+ return null;
2107
+ }
2108
+ return positionGroups;
2109
+ }
2110
+ function test4DTag(IPPGroups, value_getter) {
2111
+ const frame_groups = {};
2112
+ let first_frame_value_set = [];
2113
+ const positions = Object.keys(IPPGroups);
2114
+ for (let i = 0; i < positions.length; i++) {
2115
+ const frame_value_set = new Set();
2116
+ const frames = IPPGroups[positions[i]];
2117
+ for (let j = 0; j < frames.length; j++) {
2118
+ const frame_value = value_getter(frames[j].imageId) || 0;
2119
+ frame_groups[frame_value] = frame_groups[frame_value] || [];
2120
+ frame_groups[frame_value].push({ imageId: frames[j].imageId });
2121
+ frame_value_set.add(frame_value);
2122
+ if (frame_value_set.size - 1 < j) {
2123
+ return undefined;
2124
+ }
2125
+ }
2126
+ if (i == 0) {
2127
+ first_frame_value_set = Array.from(frame_value_set);
2128
+ }
2129
+ else if (!setEquals(first_frame_value_set, frame_value_set)) {
2130
+ return undefined;
2131
+ }
2132
+ }
2133
+ return frame_groups;
2134
+ }
2135
+ function getTagValue(imageId, tag) {
2136
+ const value = _metaData__WEBPACK_IMPORTED_MODULE_0__.get(tag, imageId);
2137
+ try {
2138
+ return parseFloat(value);
2139
+ }
2140
+ catch {
2141
+ return undefined;
2142
+ }
2143
+ }
2144
+ function getPhilipsPrivateBValue(imageId) {
2145
+ const value = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('20011003', imageId);
2146
+ try {
2147
+ const { InlineBinary } = value;
2148
+ if (InlineBinary) {
2149
+ const value_bytes = atob(InlineBinary);
2150
+ const ary_buf = new ArrayBuffer(value_bytes.length);
2151
+ const dv = new DataView(ary_buf);
2152
+ for (let i = 0; i < value_bytes.length; i++) {
2153
+ dv.setUint8(i, value_bytes.charCodeAt(i));
2154
+ }
2155
+ return new Float32Array(ary_buf)[0];
2156
+ }
2157
+ return parseFloat(value);
2158
+ }
2159
+ catch {
2160
+ return undefined;
2161
+ }
2162
+ }
2163
+ function getSiemensPrivateBValue(imageId) {
2164
+ let value = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('0019100c', imageId) || _metaData__WEBPACK_IMPORTED_MODULE_0__.get('0019100C', imageId);
2165
+ try {
2166
+ const { InlineBinary } = value;
2167
+ if (InlineBinary) {
2168
+ value = atob(InlineBinary);
2169
+ }
2170
+ return parseFloat(value);
2171
+ }
2172
+ catch {
2173
+ return undefined;
2174
+ }
2175
+ }
2176
+ function getGEPrivateBValue(imageId) {
2177
+ let value = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('00431039', imageId);
2178
+ try {
2179
+ const { InlineBinary } = value;
2180
+ if (InlineBinary) {
2181
+ value = atob(InlineBinary).split('//');
2182
+ }
2183
+ return parseFloat(value[0]) % 100000;
2184
+ }
2185
+ catch {
2186
+ return undefined;
2187
+ }
2188
+ }
2189
+ function setEquals(set_a, set_b) {
2190
+ if (set_a.length != set_b.size) {
2191
+ return false;
2192
+ }
2193
+ for (let i = 0; i < set_a.length; i++) {
2194
+ if (!set_b.has(set_a[i])) {
2195
+ return false;
2196
+ }
2197
+ }
2198
+ return true;
2199
+ }
2200
+ function getPetFrameReferenceTime(imageId) {
2201
+ const moduleInfo = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('petImageModule', imageId);
2202
+ return moduleInfo ? moduleInfo['frameReferenceTime'] : 0;
2203
+ }
2204
+ function splitImageIdsBy4DTags(imageIds) {
2205
+ const positionGroups = getIPPGroups(imageIds);
2206
+ if (!positionGroups) {
2207
+ return { imageIdGroups: [imageIds], splittingTag: null };
2208
+ }
2209
+ const tags = [
2210
+ 'TemporalPositionIdentifier',
2211
+ 'DiffusionBValue',
2212
+ 'TriggerTime',
2213
+ 'EchoTime',
2214
+ 'EchoNumber',
2215
+ 'PhilipsPrivateBValue',
2216
+ 'SiemensPrivateBValue',
2217
+ 'GEPrivateBValue',
2218
+ 'PetFrameReferenceTime',
2219
+ ];
2220
+ const fncList2 = [
2221
+ (imageId) => getTagValue(imageId, tags[0]),
2222
+ (imageId) => getTagValue(imageId, tags[1]),
2223
+ (imageId) => getTagValue(imageId, tags[2]),
2224
+ (imageId) => getTagValue(imageId, tags[3]),
2225
+ (imageId) => getTagValue(imageId, tags[4]),
2226
+ getPhilipsPrivateBValue,
2227
+ getSiemensPrivateBValue,
2228
+ getGEPrivateBValue,
2229
+ getPetFrameReferenceTime,
2230
+ ];
2231
+ for (let i = 0; i < fncList2.length; i++) {
2232
+ const frame_groups = test4DTag(positionGroups, fncList2[i]);
2233
+ if (frame_groups) {
2234
+ const sortedKeys = Object.keys(frame_groups)
2235
+ .map(Number.parseFloat)
2236
+ .sort((a, b) => a - b);
2237
+ const imageIdGroups = sortedKeys.map((key) => frame_groups[key].map((item) => item.imageId));
2238
+ return { imageIdGroups, splittingTag: tags[i] };
2239
+ }
2240
+ }
2241
+ return { imageIdGroups: [imageIds], splittingTag: null };
2242
+ }
2243
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (splitImageIdsBy4DTags);
2244
+
2245
+
2246
+ /***/ }),
2247
+
2248
+ /***/ 85745:
2249
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2250
+
2251
+ __webpack_require__.r(__webpack_exports__);
2252
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2253
+ /* harmony export */ getTransferFunctionNodes: () => (/* binding */ getTransferFunctionNodes),
2254
+ /* harmony export */ setTransferFunctionNodes: () => (/* binding */ setTransferFunctionNodes)
2255
+ /* harmony export */ });
2256
+ function getTransferFunctionNodes(transferFunction) {
2257
+ const size = transferFunction.getSize();
2258
+ const values = [];
2259
+ for (let index = 0; index < size; index++) {
2260
+ const nodeValue1 = [];
2261
+ transferFunction.getNodeValue(index, nodeValue1);
2262
+ values.push(nodeValue1);
2263
+ }
2264
+ return values;
2265
+ }
2266
+ function setTransferFunctionNodes(transferFunction, nodes) {
2267
+ if (!nodes?.length) {
2268
+ return;
2269
+ }
2270
+ transferFunction.removeAllPoints();
2271
+ nodes.forEach((node) => {
2272
+ transferFunction.addRGBPoint(...node);
2273
+ });
2274
+ }
2275
+
2276
+
2277
+
2278
+ /***/ }),
2279
+
2280
+ /***/ 38669:
2281
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2282
+
2283
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2284
+ /* harmony export */ A: () => (/* binding */ transformWorldToIndex),
2285
+ /* harmony export */ p: () => (/* binding */ transformWorldToIndexContinuous)
2286
+ /* harmony export */ });
2287
+ function transformWorldToIndex(imageData, worldPos) {
2288
+ const continuousIndex = imageData.worldToIndex(worldPos);
2289
+ const index = continuousIndex.map(Math.round);
2290
+ return index;
2291
+ }
2292
+ function transformWorldToIndexContinuous(imageData, worldPos) {
2293
+ return imageData.worldToIndex(worldPos);
2294
+ }
2295
+
2296
+
2297
+ /***/ }),
2298
+
2299
+ /***/ 68136:
2300
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2301
+
2302
+ __webpack_require__.r(__webpack_exports__);
2303
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2304
+ /* harmony export */ toLowHighRange: () => (/* binding */ toLowHighRange),
2305
+ /* harmony export */ toWindowLevel: () => (/* binding */ toWindowLevel)
2306
+ /* harmony export */ });
2307
+ /* harmony import */ var _enums_VOILUTFunctionType__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(82501);
2308
+ /* harmony import */ var _logit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(58977);
2309
+
2310
+
2311
+ function toWindowLevel(low, high) {
2312
+ const windowWidth = Math.abs(high - low) + 1;
2313
+ const windowCenter = (low + high + 1) / 2;
2314
+ return { windowWidth, windowCenter };
2315
+ }
2316
+ function toLowHighRange(windowWidth, windowCenter, voiLUTFunction = _enums_VOILUTFunctionType__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.LINEAR) {
2317
+ if (voiLUTFunction === _enums_VOILUTFunctionType__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.LINEAR) {
2318
+ return {
2319
+ lower: windowCenter - 0.5 - (windowWidth - 1) / 2,
2320
+ upper: windowCenter - 0.5 + (windowWidth - 1) / 2,
2321
+ };
2322
+ }
2323
+ else if (voiLUTFunction === _enums_VOILUTFunctionType__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.LINEAR_EXACT) {
2324
+ return {
2325
+ lower: windowCenter - windowWidth / 2,
2326
+ upper: windowCenter + windowWidth / 2,
2327
+ };
2328
+ }
2329
+ else if (voiLUTFunction === _enums_VOILUTFunctionType__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A.SAMPLED_SIGMOID) {
2330
+ const xLower = (0,_logit__WEBPACK_IMPORTED_MODULE_1__/* .logit */ .i)(0.01, windowCenter, windowWidth);
2331
+ const xUpper = (0,_logit__WEBPACK_IMPORTED_MODULE_1__/* .logit */ .i)(0.99, windowCenter, windowWidth);
2332
+ return {
2333
+ lower: xLower,
2334
+ upper: xUpper,
2335
+ };
2336
+ }
2337
+ else {
2338
+ throw new Error('Invalid VOI LUT function');
2339
+ }
2340
+ }
2341
+
2342
+
2343
+
2344
+ /***/ }),
2345
+
2346
+ /***/ 79988:
2347
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2348
+
2349
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2350
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
2351
+ /* harmony export */ });
2352
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
2353
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(74876);
2354
+
2355
+
2356
+ function worldToImageCoords(imageId, worldCoords) {
2357
+ const imagePlaneModule = (0,_metaData__WEBPACK_IMPORTED_MODULE_1__.get)('imagePlaneModule', imageId);
2358
+ if (!imagePlaneModule) {
2359
+ throw new Error(`No imagePlaneModule found for imageId: ${imageId}`);
2360
+ }
2361
+ const { columnCosines, rowCosines, imagePositionPatient: origin, } = imagePlaneModule;
2362
+ let { columnPixelSpacing, rowPixelSpacing } = imagePlaneModule;
2363
+ columnPixelSpacing ||= 1;
2364
+ rowPixelSpacing ||= 1;
2365
+ const newOrigin = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create();
2366
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.scaleAndAdd */ .eR.scaleAndAdd(newOrigin, origin, columnCosines, -columnPixelSpacing / 2);
2367
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.scaleAndAdd */ .eR.scaleAndAdd(newOrigin, newOrigin, rowCosines, -rowPixelSpacing / 2);
2368
+ const sub = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create();
2369
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.sub */ .eR.sub(sub, worldCoords, newOrigin);
2370
+ const rowDistance = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(sub, rowCosines);
2371
+ const columnDistance = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(sub, columnCosines);
2372
+ const imageCoords = [
2373
+ rowDistance / rowPixelSpacing,
2374
+ columnDistance / columnPixelSpacing,
2375
+ ];
2376
+ return imageCoords;
2377
+ }
2378
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (worldToImageCoords);
2379
+
2380
+
2381
+ /***/ }),
2382
+
2383
+ /***/ 4667:
2384
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2385
+
2386
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2387
+ /* harmony export */ utilities: () => (/* reexport module object */ _utilities__WEBPACK_IMPORTED_MODULE_6__)
2388
+ /* harmony export */ });
2389
+ /* harmony import */ var _init__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(23391);
2390
+ /* harmony import */ var _store__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15900);
2391
+ /* harmony import */ var _store_state__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(85204);
2392
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(47085);
2393
+ /* harmony import */ var _synchronizers__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(93106);
2394
+ /* harmony import */ var _drawingSvg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(89578);
2395
+ /* harmony import */ var _utilities__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(23566);
2396
+ /* harmony import */ var _cursors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(79475);
2397
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(13369);
2398
+ /* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_types__WEBPACK_IMPORTED_MODULE_8__);
2399
+ /* harmony import */ var _stateManagement_annotation__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(32102);
2400
+ /* harmony import */ var _stateManagement_segmentation__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(44595);
2401
+ /* harmony import */ var _tools_annotation_splines__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(30453);
2402
+ /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(67460);
2403
+ /* harmony import */ var _tools_annotation_VideoRedactionTool__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(11811);
2404
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(99737);
2405
+
2406
+
2407
+
2408
+
2409
+
2410
+
2411
+
2412
+
2413
+
2414
+
2415
+
2416
+
2417
+
2418
+
2419
+
2420
+
2421
+
2422
+
2423
+
2424
+ /***/ }),
2425
+
2426
+ /***/ 53005:
2427
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2428
+
2429
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2430
+ /* harmony export */ getState: () => (/* reexport safe */ _getState__WEBPACK_IMPORTED_MODULE_0__.A),
2431
+ /* harmony export */ style: () => (/* reexport safe */ _ToolStyle__WEBPACK_IMPORTED_MODULE_2__.A)
2432
+ /* harmony export */ });
2433
+ /* harmony import */ var _getState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(75892);
2434
+ /* harmony import */ var _getFont__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(61816);
2435
+ /* harmony import */ var _ToolStyle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8710);
2436
+
2437
+
2438
+
2439
+
2440
+
2441
+
2442
+ /***/ }),
2443
+
2444
+ /***/ 32102:
2445
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2446
+
2447
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2448
+ /* harmony export */ config: () => (/* reexport module object */ _config__WEBPACK_IMPORTED_MODULE_0__),
2449
+ /* harmony export */ state: () => (/* binding */ state)
2450
+ /* harmony export */ });
2451
+ /* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(53005);
2452
+ /* harmony import */ var _annotationLocking__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2076);
2453
+ /* harmony import */ var _annotationSelection__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17343);
2454
+ /* harmony import */ var _annotationState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(82056);
2455
+ /* harmony import */ var _helpers_state__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(44049);
2456
+ /* harmony import */ var _annotationVisibility__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(29601);
2457
+ /* harmony import */ var _FrameOfReferenceSpecificAnnotationManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(67013);
2458
+ /* harmony import */ var _AnnotationGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(90826);
2459
+ /* harmony import */ var _resetAnnotationManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(97);
2460
+
2461
+
2462
+
2463
+
2464
+
2465
+
2466
+
2467
+
2468
+
2469
+ const state = {
2470
+ ..._annotationState__WEBPACK_IMPORTED_MODULE_3__,
2471
+ ..._helpers_state__WEBPACK_IMPORTED_MODULE_4__,
2472
+ resetAnnotationManager: _resetAnnotationManager__WEBPACK_IMPORTED_MODULE_8__/* .resetAnnotationManager */ .c,
2473
+ };
2474
+
2475
+
2476
+
2477
+ /***/ }),
2478
+
2479
+ /***/ 24917:
2480
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2481
+
2482
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2483
+ /* harmony export */ fy: () => (/* binding */ triggerSegmentationRenderBySegmentationId),
2484
+ /* harmony export */ h6: () => (/* binding */ triggerSegmentationRender)
2485
+ /* harmony export */ });
2486
+ /* unused harmony export segmentationRenderingEngine */
2487
+ /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81985);
2488
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(99737);
2489
+ /* harmony import */ var _enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(18682);
2490
+ /* harmony import */ var _getSegmentationRepresentation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(93210);
2491
+ /* harmony import */ var _tools_displayTools_Surface_surfaceDisplay__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(67014);
2492
+ /* harmony import */ var _tools_displayTools_Contour_contourDisplay__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(25894);
2493
+ /* harmony import */ var _tools_displayTools_Labelmap_labelmapDisplay__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(684);
2494
+ /* harmony import */ var _store_addTool__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(68040);
2495
+ /* harmony import */ var _store_state__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(85204);
2496
+ /* harmony import */ var _tools_annotation_PlanarFreehandContourSegmentationTool__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(37590);
2497
+ /* harmony import */ var _store_ToolGroupManager__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(7754);
2498
+
2499
+
2500
+
2501
+
2502
+
2503
+
2504
+
2505
+
2506
+
2507
+
2508
+
2509
+ const renderers = {
2510
+ [_enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A.Labelmap]: _tools_displayTools_Labelmap_labelmapDisplay__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .Ay,
2511
+ [_enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A.Contour]: _tools_displayTools_Contour_contourDisplay__WEBPACK_IMPORTED_MODULE_5__/* ["default"] */ .A,
2512
+ [_enums_SegmentationRepresentations__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A.Surface]: _tools_displayTools_Surface_surfaceDisplay__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .Ay,
2513
+ };
2514
+ const planarContourToolName = _tools_annotation_PlanarFreehandContourSegmentationTool__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A.toolName;
2515
+ class SegmentationRenderingEngine {
2516
+ constructor() {
2517
+ this._needsRender = new Set();
2518
+ this._animationFrameSet = false;
2519
+ this._animationFrameHandle = null;
2520
+ this._getAllViewports = () => {
2521
+ const renderingEngine = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getRenderingEngines)();
2522
+ return renderingEngine.flatMap((renderingEngine) => renderingEngine.getViewports());
2523
+ };
2524
+ this._renderFlaggedSegmentations = () => {
2525
+ this._throwIfDestroyed();
2526
+ const viewportIds = Array.from(this._needsRender);
2527
+ viewportIds.forEach((viewportId) => {
2528
+ this._triggerRender(viewportId);
2529
+ });
2530
+ this._needsRender.clear();
2531
+ this._animationFrameSet = false;
2532
+ this._animationFrameHandle = null;
2533
+ };
2534
+ }
2535
+ renderSegmentationsForViewport(viewportId) {
2536
+ const viewportIds = viewportId
2537
+ ? [viewportId]
2538
+ : this._getViewportIdsForSegmentation();
2539
+ this._setViewportsToBeRenderedNextFrame(viewportIds);
2540
+ }
2541
+ renderSegmentation(segmentationId) {
2542
+ const viewportIds = this._getViewportIdsForSegmentation(segmentationId);
2543
+ this._setViewportsToBeRenderedNextFrame(viewportIds);
2544
+ }
2545
+ _getViewportIdsForSegmentation(segmentationId) {
2546
+ const viewports = this._getAllViewports();
2547
+ const viewportIds = [];
2548
+ for (const viewport of viewports) {
2549
+ const viewportId = viewport.id;
2550
+ if (segmentationId) {
2551
+ const segmentationRepresentations = (0,_getSegmentationRepresentation__WEBPACK_IMPORTED_MODULE_3__/* .getSegmentationRepresentations */ .r$)(viewportId, { segmentationId });
2552
+ if (segmentationRepresentations?.length > 0) {
2553
+ viewportIds.push(viewportId);
2554
+ }
2555
+ }
2556
+ else {
2557
+ const segmentationRepresentations = (0,_getSegmentationRepresentation__WEBPACK_IMPORTED_MODULE_3__/* .getSegmentationRepresentations */ .r$)(viewportId);
2558
+ if (segmentationRepresentations?.length > 0) {
2559
+ viewportIds.push(viewportId);
2560
+ }
2561
+ }
2562
+ }
2563
+ return viewportIds;
2564
+ }
2565
+ _throwIfDestroyed() {
2566
+ if (this.hasBeenDestroyed) {
2567
+ throw new Error('this.destroy() has been manually called to free up memory, can not longer use this instance. Instead make a new one.');
2568
+ }
2569
+ }
2570
+ _setViewportsToBeRenderedNextFrame(viewportIds) {
2571
+ viewportIds.forEach((viewportId) => {
2572
+ this._needsRender.add(viewportId);
2573
+ });
2574
+ this._render();
2575
+ }
2576
+ _render() {
2577
+ if (this._needsRender.size > 0 && this._animationFrameSet === false) {
2578
+ this._animationFrameHandle = window.requestAnimationFrame(this._renderFlaggedSegmentations);
2579
+ this._animationFrameSet = true;
2580
+ }
2581
+ }
2582
+ _triggerRender(viewportId) {
2583
+ const segmentationRepresentations = (0,_getSegmentationRepresentation__WEBPACK_IMPORTED_MODULE_3__/* .getSegmentationRepresentations */ .r$)(viewportId);
2584
+ if (!segmentationRepresentations?.length) {
2585
+ return;
2586
+ }
2587
+ const { viewport } = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getEnabledElementByViewportId)(viewportId) || {};
2588
+ if (!viewport) {
2589
+ return;
2590
+ }
2591
+ const viewportRenderList = [];
2592
+ const segmentationRenderList = segmentationRepresentations.map((representation) => {
2593
+ if (representation.type === _enums__WEBPACK_IMPORTED_MODULE_1__.SegmentationRepresentations.Contour) {
2594
+ this._addPlanarFreeHandToolIfAbsent(viewport);
2595
+ }
2596
+ const display = renderers[representation.type];
2597
+ try {
2598
+ const viewportId = display.render(viewport, representation);
2599
+ viewportRenderList.push(viewportId);
2600
+ }
2601
+ catch (error) {
2602
+ console.error(error);
2603
+ }
2604
+ return Promise.resolve({
2605
+ segmentationId: representation.segmentationId,
2606
+ type: representation.type,
2607
+ });
2608
+ });
2609
+ Promise.allSettled(segmentationRenderList).then((results) => {
2610
+ const segmentationDetails = results
2611
+ .filter((r) => r.status === 'fulfilled')
2612
+ .map((r) => r.value);
2613
+ function onSegmentationRender(evt) {
2614
+ const { element, viewportId } = evt.detail;
2615
+ element.removeEventListener(_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.Enums.Events.IMAGE_RENDERED, onSegmentationRender);
2616
+ segmentationDetails.forEach((detail) => {
2617
+ const eventDetail = {
2618
+ viewportId,
2619
+ segmentationId: detail.segmentationId,
2620
+ type: detail.type,
2621
+ };
2622
+ (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.triggerEvent)(_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.eventTarget, _enums__WEBPACK_IMPORTED_MODULE_1__.Events.SEGMENTATION_RENDERED, {
2623
+ ...eventDetail,
2624
+ });
2625
+ });
2626
+ }
2627
+ const element = viewport.element;
2628
+ element.addEventListener(_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.Enums.Events.IMAGE_RENDERED, onSegmentationRender);
2629
+ viewport.render();
2630
+ });
2631
+ }
2632
+ _addPlanarFreeHandToolIfAbsent(viewport) {
2633
+ if (!(planarContourToolName in _store_state__WEBPACK_IMPORTED_MODULE_8__/* .state */ .wk.tools)) {
2634
+ (0,_store_addTool__WEBPACK_IMPORTED_MODULE_7__/* .addTool */ .Gx)(_tools_annotation_PlanarFreehandContourSegmentationTool__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A);
2635
+ }
2636
+ const toolGroup = (0,_store_ToolGroupManager__WEBPACK_IMPORTED_MODULE_10__.getToolGroupForViewport)(viewport.id);
2637
+ if (!toolGroup.hasTool(planarContourToolName)) {
2638
+ toolGroup.addTool(planarContourToolName);
2639
+ toolGroup.setToolPassive(planarContourToolName);
2640
+ }
2641
+ }
2642
+ }
2643
+ function triggerSegmentationRender(viewportId) {
2644
+ segmentationRenderingEngine.renderSegmentationsForViewport(viewportId);
2645
+ }
2646
+ function triggerSegmentationRenderBySegmentationId(segmentationId) {
2647
+ segmentationRenderingEngine.renderSegmentation(segmentationId);
2648
+ }
2649
+ const segmentationRenderingEngine = new SegmentationRenderingEngine();
2650
+
2651
+
2652
+
2653
+ /***/ }),
2654
+
2655
+ /***/ 25072:
2656
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2657
+
2658
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2659
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
2660
+ /* harmony export */ });
2661
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
2662
+ /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(81985);
2663
+ /* harmony import */ var _utilities_getCalibratedUnits__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4096);
2664
+ /* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(85817);
2665
+ /* harmony import */ var _utilities_throttle__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(27730);
2666
+ /* harmony import */ var _stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(82056);
2667
+ /* harmony import */ var _stateManagement_annotation_annotationLocking__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2076);
2668
+ /* harmony import */ var _stateManagement_annotation_annotationVisibility__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(29601);
2669
+ /* harmony import */ var _stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(44049);
2670
+ /* harmony import */ var _drawingSvg__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(89578);
2671
+ /* harmony import */ var _store_state__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(85204);
2672
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(99737);
2673
+ /* harmony import */ var _utilities_viewportFilters__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(60810);
2674
+ /* harmony import */ var _utilities_math_line__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(5956);
2675
+ /* harmony import */ var _utilities_drawing__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(66990);
2676
+ /* harmony import */ var _cursors_elementCursor__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(7001);
2677
+ /* harmony import */ var _utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(58640);
2678
+
2679
+
2680
+
2681
+
2682
+
2683
+
2684
+
2685
+
2686
+
2687
+
2688
+
2689
+
2690
+
2691
+
2692
+
2693
+
2694
+
2695
+ const { transformWorldToIndex } = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities;
2696
+ class BidirectionalTool extends _base__WEBPACK_IMPORTED_MODULE_3__/* .AnnotationTool */ .EC {
2697
+ static { this.toolName = 'Bidirectional'; }
2698
+ constructor(toolProps = {}, defaultToolProps = {
2699
+ supportedInteractionTypes: ['Mouse', 'Touch'],
2700
+ configuration: {
2701
+ preventHandleOutsideImage: false,
2702
+ getTextLines: defaultGetTextLines,
2703
+ },
2704
+ }) {
2705
+ super(toolProps, defaultToolProps);
2706
+ this.isPointNearTool = (element, annotation, canvasCoords, proximity) => {
2707
+ const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.getEnabledElement)(element);
2708
+ const { viewport } = enabledElement;
2709
+ const { data } = annotation;
2710
+ const { points } = data.handles;
2711
+ let canvasPoint1 = viewport.worldToCanvas(points[0]);
2712
+ let canvasPoint2 = viewport.worldToCanvas(points[1]);
2713
+ let line = {
2714
+ start: {
2715
+ x: canvasPoint1[0],
2716
+ y: canvasPoint1[1],
2717
+ },
2718
+ end: {
2719
+ x: canvasPoint2[0],
2720
+ y: canvasPoint2[1],
2721
+ },
2722
+ };
2723
+ let distanceToPoint = _utilities_math_line__WEBPACK_IMPORTED_MODULE_13__.distanceToPoint([line.start.x, line.start.y], [line.end.x, line.end.y], [canvasCoords[0], canvasCoords[1]]);
2724
+ if (distanceToPoint <= proximity) {
2725
+ return true;
2726
+ }
2727
+ canvasPoint1 = viewport.worldToCanvas(points[2]);
2728
+ canvasPoint2 = viewport.worldToCanvas(points[3]);
2729
+ line = {
2730
+ start: {
2731
+ x: canvasPoint1[0],
2732
+ y: canvasPoint1[1],
2733
+ },
2734
+ end: {
2735
+ x: canvasPoint2[0],
2736
+ y: canvasPoint2[1],
2737
+ },
2738
+ };
2739
+ distanceToPoint = _utilities_math_line__WEBPACK_IMPORTED_MODULE_13__.distanceToPoint([line.start.x, line.start.y], [line.end.x, line.end.y], [canvasCoords[0], canvasCoords[1]]);
2740
+ if (distanceToPoint <= proximity) {
2741
+ return true;
2742
+ }
2743
+ return false;
2744
+ };
2745
+ this.toolSelectedCallback = (evt, annotation) => {
2746
+ const eventDetail = evt.detail;
2747
+ const { element } = eventDetail;
2748
+ annotation.highlighted = true;
2749
+ const viewportIdsToRender = (0,_utilities_viewportFilters__WEBPACK_IMPORTED_MODULE_12__.getViewportIdsWithToolToRender)(element, this.getToolName());
2750
+ this.editData = {
2751
+ annotation,
2752
+ viewportIdsToRender,
2753
+ movingTextBox: false,
2754
+ };
2755
+ this._activateModify(element);
2756
+ const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.getEnabledElement)(element);
2757
+ const { renderingEngine } = enabledElement;
2758
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_16__/* ["default"] */ .A)(viewportIdsToRender);
2759
+ (0,_cursors_elementCursor__WEBPACK_IMPORTED_MODULE_15__.hideElementCursor)(element);
2760
+ evt.preventDefault();
2761
+ };
2762
+ this.handleSelectedCallback = (evt, annotation, handle) => {
2763
+ const eventDetail = evt.detail;
2764
+ const { element } = eventDetail;
2765
+ const data = annotation.data;
2766
+ annotation.highlighted = true;
2767
+ let movingTextBox = false;
2768
+ let handleIndex;
2769
+ if (handle.worldPosition) {
2770
+ movingTextBox = true;
2771
+ }
2772
+ else {
2773
+ handleIndex = data.handles.points.findIndex((p) => p === handle);
2774
+ }
2775
+ const viewportIdsToRender = (0,_utilities_viewportFilters__WEBPACK_IMPORTED_MODULE_12__.getViewportIdsWithToolToRender)(element, this.getToolName());
2776
+ (0,_cursors_elementCursor__WEBPACK_IMPORTED_MODULE_15__.hideElementCursor)(element);
2777
+ this.editData = {
2778
+ annotation,
2779
+ viewportIdsToRender,
2780
+ handleIndex,
2781
+ movingTextBox,
2782
+ };
2783
+ this._activateModify(element);
2784
+ const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.getEnabledElement)(element);
2785
+ const { renderingEngine } = enabledElement;
2786
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_16__/* ["default"] */ .A)(viewportIdsToRender);
2787
+ evt.preventDefault();
2788
+ };
2789
+ this._endCallback = (evt) => {
2790
+ const eventDetail = evt.detail;
2791
+ const { element } = eventDetail;
2792
+ const { annotation, viewportIdsToRender, newAnnotation, hasMoved } = this.editData;
2793
+ const { data } = annotation;
2794
+ if (newAnnotation && !hasMoved) {
2795
+ return;
2796
+ }
2797
+ this.doneEditMemo();
2798
+ data.handles.activeHandleIndex = null;
2799
+ this._deactivateModify(element);
2800
+ this._deactivateDraw(element);
2801
+ (0,_cursors_elementCursor__WEBPACK_IMPORTED_MODULE_15__.resetElementCursor)(element);
2802
+ const { renderingEngine } = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.getEnabledElement)(element);
2803
+ if (this.editData.handleIndex !== undefined) {
2804
+ const { points } = data.handles;
2805
+ const firstLineSegmentLength = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.distance */ .eR.distance(points[0], points[1]);
2806
+ const secondLineSegmentLength = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.distance */ .eR.distance(points[2], points[3]);
2807
+ if (secondLineSegmentLength > firstLineSegmentLength) {
2808
+ const longAxis = [[...points[2]], [...points[3]]];
2809
+ const shortAxisPoint0 = [...points[0]];
2810
+ const shortAxisPoint1 = [...points[1]];
2811
+ const longAxisVector = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.create */ .Zc.create();
2812
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.set */ .Zc.set(longAxisVector, longAxis[1][0] - longAxis[0][0], longAxis[1][1] - longAxis[1][0]);
2813
+ const counterClockWisePerpendicularToLongAxis = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.create */ .Zc.create();
2814
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.set */ .Zc.set(counterClockWisePerpendicularToLongAxis, -longAxisVector[1], longAxisVector[0]);
2815
+ const currentShortAxisVector = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.create */ .Zc.create();
2816
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.set */ .Zc.set(currentShortAxisVector, shortAxisPoint1[0] - shortAxisPoint0[0], shortAxisPoint1[1] - shortAxisPoint0[0]);
2817
+ let shortAxis;
2818
+ if (gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.dot */ .Zc.dot(currentShortAxisVector, counterClockWisePerpendicularToLongAxis) > 0) {
2819
+ shortAxis = [shortAxisPoint0, shortAxisPoint1];
2820
+ }
2821
+ else {
2822
+ shortAxis = [shortAxisPoint1, shortAxisPoint0];
2823
+ }
2824
+ data.handles.points = [
2825
+ longAxis[0],
2826
+ longAxis[1],
2827
+ shortAxis[0],
2828
+ shortAxis[1],
2829
+ ];
2830
+ }
2831
+ }
2832
+ if (this.isHandleOutsideImage &&
2833
+ this.configuration.preventHandleOutsideImage) {
2834
+ (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_5__.removeAnnotation)(annotation.annotationUID);
2835
+ }
2836
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_16__/* ["default"] */ .A)(viewportIdsToRender);
2837
+ if (newAnnotation) {
2838
+ (0,_stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_8__.triggerAnnotationCompleted)(annotation);
2839
+ }
2840
+ this.editData = null;
2841
+ this.isDrawing = false;
2842
+ };
2843
+ this._dragDrawCallback = (evt) => {
2844
+ this.isDrawing = true;
2845
+ const eventDetail = evt.detail;
2846
+ const { currentPoints, element } = eventDetail;
2847
+ const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.getEnabledElement)(element);
2848
+ const { viewport } = enabledElement;
2849
+ const { worldToCanvas } = viewport;
2850
+ const { annotation, viewportIdsToRender, handleIndex, newAnnotation } = this.editData;
2851
+ this.createMemo(element, annotation, { newAnnotation });
2852
+ const { data } = annotation;
2853
+ const worldPos = currentPoints.world;
2854
+ data.handles.points[handleIndex] = [...worldPos];
2855
+ const canvasCoordPoints = data.handles.points.map(worldToCanvas);
2856
+ const canvasCoords = {
2857
+ longLineSegment: {
2858
+ start: {
2859
+ x: canvasCoordPoints[0][0],
2860
+ y: canvasCoordPoints[0][1],
2861
+ },
2862
+ end: {
2863
+ x: canvasCoordPoints[1][0],
2864
+ y: canvasCoordPoints[1][1],
2865
+ },
2866
+ },
2867
+ shortLineSegment: {
2868
+ start: {
2869
+ x: canvasCoordPoints[2][0],
2870
+ y: canvasCoordPoints[2][1],
2871
+ },
2872
+ end: {
2873
+ x: canvasCoordPoints[3][0],
2874
+ y: canvasCoordPoints[3][1],
2875
+ },
2876
+ },
2877
+ };
2878
+ const dist = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.distance */ .Zc.distance(canvasCoordPoints[0], canvasCoordPoints[1]);
2879
+ const shortAxisDistFromCenter = dist / 3;
2880
+ const dx = canvasCoords.longLineSegment.start.x - canvasCoords.longLineSegment.end.x;
2881
+ const dy = canvasCoords.longLineSegment.start.y - canvasCoords.longLineSegment.end.y;
2882
+ const length = Math.sqrt(dx * dx + dy * dy);
2883
+ const vectorX = dx / length;
2884
+ const vectorY = dy / length;
2885
+ const xMid = (canvasCoords.longLineSegment.start.x +
2886
+ canvasCoords.longLineSegment.end.x) /
2887
+ 2;
2888
+ const yMid = (canvasCoords.longLineSegment.start.y +
2889
+ canvasCoords.longLineSegment.end.y) /
2890
+ 2;
2891
+ const startX = xMid + shortAxisDistFromCenter * vectorY;
2892
+ const startY = yMid - shortAxisDistFromCenter * vectorX;
2893
+ const endX = xMid - shortAxisDistFromCenter * vectorY;
2894
+ const endY = yMid + shortAxisDistFromCenter * vectorX;
2895
+ data.handles.points[2] = viewport.canvasToWorld([startX, startY]);
2896
+ data.handles.points[3] = viewport.canvasToWorld([endX, endY]);
2897
+ annotation.invalidated = true;
2898
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_16__/* ["default"] */ .A)(viewportIdsToRender);
2899
+ this.editData.hasMoved = true;
2900
+ };
2901
+ this._dragModifyCallback = (evt) => {
2902
+ this.isDrawing = true;
2903
+ const eventDetail = evt.detail;
2904
+ const { element } = eventDetail;
2905
+ const { annotation, viewportIdsToRender, handleIndex, movingTextBox, newAnnotation, } = this.editData;
2906
+ this.createMemo(element, annotation, { newAnnotation });
2907
+ const { data } = annotation;
2908
+ if (movingTextBox) {
2909
+ const { deltaPoints } = eventDetail;
2910
+ const worldPosDelta = deltaPoints.world;
2911
+ const { textBox } = data.handles;
2912
+ const { worldPosition } = textBox;
2913
+ worldPosition[0] += worldPosDelta[0];
2914
+ worldPosition[1] += worldPosDelta[1];
2915
+ worldPosition[2] += worldPosDelta[2];
2916
+ textBox.hasMoved = true;
2917
+ }
2918
+ else if (handleIndex === undefined) {
2919
+ const { deltaPoints } = eventDetail;
2920
+ const worldPosDelta = deltaPoints.world;
2921
+ const points = data.handles.points;
2922
+ points.forEach((point) => {
2923
+ point[0] += worldPosDelta[0];
2924
+ point[1] += worldPosDelta[1];
2925
+ point[2] += worldPosDelta[2];
2926
+ });
2927
+ annotation.invalidated = true;
2928
+ }
2929
+ else {
2930
+ this._dragModifyHandle(evt);
2931
+ annotation.invalidated = true;
2932
+ }
2933
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_16__/* ["default"] */ .A)(viewportIdsToRender);
2934
+ };
2935
+ this._dragModifyHandle = (evt) => {
2936
+ const eventDetail = evt.detail;
2937
+ const { currentPoints, element } = eventDetail;
2938
+ const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.getEnabledElement)(element);
2939
+ const { viewport } = enabledElement;
2940
+ const { annotation, handleIndex: movingHandleIndex } = this.editData;
2941
+ const { data } = annotation;
2942
+ const worldPos = currentPoints.world;
2943
+ const canvasCoordHandlesCurrent = [
2944
+ viewport.worldToCanvas(data.handles.points[0]),
2945
+ viewport.worldToCanvas(data.handles.points[1]),
2946
+ viewport.worldToCanvas(data.handles.points[2]),
2947
+ viewport.worldToCanvas(data.handles.points[3]),
2948
+ ];
2949
+ const firstLineSegment = {
2950
+ start: {
2951
+ x: canvasCoordHandlesCurrent[0][0],
2952
+ y: canvasCoordHandlesCurrent[0][1],
2953
+ },
2954
+ end: {
2955
+ x: canvasCoordHandlesCurrent[1][0],
2956
+ y: canvasCoordHandlesCurrent[1][1],
2957
+ },
2958
+ };
2959
+ const secondLineSegment = {
2960
+ start: {
2961
+ x: canvasCoordHandlesCurrent[2][0],
2962
+ y: canvasCoordHandlesCurrent[2][1],
2963
+ },
2964
+ end: {
2965
+ x: canvasCoordHandlesCurrent[3][0],
2966
+ y: canvasCoordHandlesCurrent[3][1],
2967
+ },
2968
+ };
2969
+ const proposedPoint = [...worldPos];
2970
+ const proposedCanvasCoord = viewport.worldToCanvas(proposedPoint);
2971
+ if (movingHandleIndex === 0 || movingHandleIndex === 1) {
2972
+ const fixedHandleIndex = movingHandleIndex === 0 ? 1 : 0;
2973
+ const fixedHandleCanvasCoord = canvasCoordHandlesCurrent[fixedHandleIndex];
2974
+ const fixedHandleToProposedCoordVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.set */ .Zc.set(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.create */ .Zc.create(), proposedCanvasCoord[0] - fixedHandleCanvasCoord[0], proposedCanvasCoord[1] - fixedHandleCanvasCoord[1]);
2975
+ const fixedHandleToOldCoordVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.set */ .Zc.set(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.create */ .Zc.create(), canvasCoordHandlesCurrent[movingHandleIndex][0] -
2976
+ fixedHandleCanvasCoord[0], canvasCoordHandlesCurrent[movingHandleIndex][1] -
2977
+ fixedHandleCanvasCoord[1]);
2978
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.normalize */ .Zc.normalize(fixedHandleToProposedCoordVec, fixedHandleToProposedCoordVec);
2979
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.normalize */ .Zc.normalize(fixedHandleToOldCoordVec, fixedHandleToOldCoordVec);
2980
+ const proposedFirstLineSegment = {
2981
+ start: {
2982
+ x: fixedHandleCanvasCoord[0],
2983
+ y: fixedHandleCanvasCoord[1],
2984
+ },
2985
+ end: {
2986
+ x: proposedCanvasCoord[0],
2987
+ y: proposedCanvasCoord[1],
2988
+ },
2989
+ };
2990
+ if (this._movingLongAxisWouldPutItThroughShortAxis(proposedFirstLineSegment, secondLineSegment)) {
2991
+ return;
2992
+ }
2993
+ const centerOfRotation = fixedHandleCanvasCoord;
2994
+ const angle = this._getSignedAngle(fixedHandleToOldCoordVec, fixedHandleToProposedCoordVec);
2995
+ let firstPointX = canvasCoordHandlesCurrent[2][0];
2996
+ let firstPointY = canvasCoordHandlesCurrent[2][1];
2997
+ let secondPointX = canvasCoordHandlesCurrent[3][0];
2998
+ let secondPointY = canvasCoordHandlesCurrent[3][1];
2999
+ firstPointX -= centerOfRotation[0];
3000
+ firstPointY -= centerOfRotation[1];
3001
+ secondPointX -= centerOfRotation[0];
3002
+ secondPointY -= centerOfRotation[1];
3003
+ const rotatedFirstPoint = firstPointX * Math.cos(angle) - firstPointY * Math.sin(angle);
3004
+ const rotatedFirstPointY = firstPointX * Math.sin(angle) + firstPointY * Math.cos(angle);
3005
+ const rotatedSecondPoint = secondPointX * Math.cos(angle) - secondPointY * Math.sin(angle);
3006
+ const rotatedSecondPointY = secondPointX * Math.sin(angle) + secondPointY * Math.cos(angle);
3007
+ firstPointX = rotatedFirstPoint + centerOfRotation[0];
3008
+ firstPointY = rotatedFirstPointY + centerOfRotation[1];
3009
+ secondPointX = rotatedSecondPoint + centerOfRotation[0];
3010
+ secondPointY = rotatedSecondPointY + centerOfRotation[1];
3011
+ const newFirstPoint = viewport.canvasToWorld([firstPointX, firstPointY]);
3012
+ const newSecondPoint = viewport.canvasToWorld([
3013
+ secondPointX,
3014
+ secondPointY,
3015
+ ]);
3016
+ data.handles.points[movingHandleIndex] = proposedPoint;
3017
+ data.handles.points[2] = newFirstPoint;
3018
+ data.handles.points[3] = newSecondPoint;
3019
+ }
3020
+ else {
3021
+ const translateHandleIndex = movingHandleIndex === 2 ? 3 : 2;
3022
+ const canvasCoordsCurrent = {
3023
+ longLineSegment: {
3024
+ start: firstLineSegment.start,
3025
+ end: firstLineSegment.end,
3026
+ },
3027
+ shortLineSegment: {
3028
+ start: secondLineSegment.start,
3029
+ end: secondLineSegment.end,
3030
+ },
3031
+ };
3032
+ const longLineSegmentVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.subtract */ .Zc.subtract(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.create */ .Zc.create(), [
3033
+ canvasCoordsCurrent.longLineSegment.end.x,
3034
+ canvasCoordsCurrent.longLineSegment.end.y,
3035
+ ], [
3036
+ canvasCoordsCurrent.longLineSegment.start.x,
3037
+ canvasCoordsCurrent.longLineSegment.start.y,
3038
+ ]);
3039
+ const longLineSegmentVecNormalized = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.normalize */ .Zc.normalize(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.create */ .Zc.create(), longLineSegmentVec);
3040
+ const proposedToCurrentVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.subtract */ .Zc.subtract(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.create */ .Zc.create(), [proposedCanvasCoord[0], proposedCanvasCoord[1]], [
3041
+ canvasCoordHandlesCurrent[movingHandleIndex][0],
3042
+ canvasCoordHandlesCurrent[movingHandleIndex][1],
3043
+ ]);
3044
+ const movementLength = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.length */ .Zc.length(proposedToCurrentVec);
3045
+ const angle = this._getSignedAngle(longLineSegmentVecNormalized, proposedToCurrentVec);
3046
+ const movementAlongLineSegmentLength = Math.cos(angle) * movementLength;
3047
+ const newTranslatedPoint = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.scaleAndAdd */ .Zc.scaleAndAdd(gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.create */ .Zc.create(), [
3048
+ canvasCoordHandlesCurrent[translateHandleIndex][0],
3049
+ canvasCoordHandlesCurrent[translateHandleIndex][1],
3050
+ ], longLineSegmentVecNormalized, movementAlongLineSegmentLength);
3051
+ if (this._movingLongAxisWouldPutItThroughShortAxis({
3052
+ start: {
3053
+ x: proposedCanvasCoord[0],
3054
+ y: proposedCanvasCoord[1],
3055
+ },
3056
+ end: {
3057
+ x: newTranslatedPoint[0],
3058
+ y: newTranslatedPoint[1],
3059
+ },
3060
+ }, {
3061
+ start: {
3062
+ x: canvasCoordsCurrent.longLineSegment.start.x,
3063
+ y: canvasCoordsCurrent.longLineSegment.start.y,
3064
+ },
3065
+ end: {
3066
+ x: canvasCoordsCurrent.longLineSegment.end.x,
3067
+ y: canvasCoordsCurrent.longLineSegment.end.y,
3068
+ },
3069
+ })) {
3070
+ return;
3071
+ }
3072
+ const intersectionPoint = _utilities_math_line__WEBPACK_IMPORTED_MODULE_13__.intersectLine([proposedCanvasCoord[0], proposedCanvasCoord[1]], [newTranslatedPoint[0], newTranslatedPoint[1]], [firstLineSegment.start.x, firstLineSegment.start.y], [firstLineSegment.end.x, firstLineSegment.end.y]);
3073
+ if (!intersectionPoint) {
3074
+ return;
3075
+ }
3076
+ data.handles.points[translateHandleIndex] = viewport.canvasToWorld(newTranslatedPoint);
3077
+ data.handles.points[movingHandleIndex] = proposedPoint;
3078
+ }
3079
+ };
3080
+ this.cancel = (element) => {
3081
+ if (this.isDrawing) {
3082
+ this.isDrawing = false;
3083
+ this._deactivateDraw(element);
3084
+ this._deactivateModify(element);
3085
+ (0,_cursors_elementCursor__WEBPACK_IMPORTED_MODULE_15__.resetElementCursor)(element);
3086
+ const { annotation, viewportIdsToRender, newAnnotation } = this.editData;
3087
+ const { data } = annotation;
3088
+ annotation.highlighted = false;
3089
+ data.handles.activeHandleIndex = null;
3090
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_16__/* ["default"] */ .A)(viewportIdsToRender);
3091
+ if (newAnnotation) {
3092
+ (0,_stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_8__.triggerAnnotationCompleted)(annotation);
3093
+ }
3094
+ this.editData = null;
3095
+ return annotation.annotationUID;
3096
+ }
3097
+ };
3098
+ this._activateDraw = (element) => {
3099
+ _store_state__WEBPACK_IMPORTED_MODULE_10__/* .state */ .wk.isInteractingWithTool = true;
3100
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_UP, this._endCallback);
3101
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_DRAG, this._dragDrawCallback);
3102
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_MOVE, this._dragDrawCallback);
3103
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_CLICK, this._endCallback);
3104
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_TAP, this._endCallback);
3105
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_END, this._endCallback);
3106
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_DRAG, this._dragDrawCallback);
3107
+ };
3108
+ this._deactivateDraw = (element) => {
3109
+ _store_state__WEBPACK_IMPORTED_MODULE_10__/* .state */ .wk.isInteractingWithTool = false;
3110
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_UP, this._endCallback);
3111
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_DRAG, this._dragDrawCallback);
3112
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_MOVE, this._dragDrawCallback);
3113
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_CLICK, this._endCallback);
3114
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_TAP, this._endCallback);
3115
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_END, this._endCallback);
3116
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_DRAG, this._dragDrawCallback);
3117
+ };
3118
+ this._activateModify = (element) => {
3119
+ _store_state__WEBPACK_IMPORTED_MODULE_10__/* .state */ .wk.isInteractingWithTool = true;
3120
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_UP, this._endCallback);
3121
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_DRAG, this._dragModifyCallback);
3122
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_CLICK, this._endCallback);
3123
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_END, this._endCallback);
3124
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_DRAG, this._dragModifyCallback);
3125
+ element.addEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_TAP, this._endCallback);
3126
+ };
3127
+ this._deactivateModify = (element) => {
3128
+ _store_state__WEBPACK_IMPORTED_MODULE_10__/* .state */ .wk.isInteractingWithTool = false;
3129
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_UP, this._endCallback);
3130
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_DRAG, this._dragModifyCallback);
3131
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.MOUSE_CLICK, this._endCallback);
3132
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_END, this._endCallback);
3133
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_DRAG, this._dragModifyCallback);
3134
+ element.removeEventListener(_enums__WEBPACK_IMPORTED_MODULE_11__.Events.TOUCH_TAP, this._endCallback);
3135
+ };
3136
+ this.renderAnnotation = (enabledElement, svgDrawingHelper) => {
3137
+ let renderStatus = true;
3138
+ const { viewport } = enabledElement;
3139
+ const { element } = viewport;
3140
+ let annotations = (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_5__.getAnnotations)(this.getToolName(), element);
3141
+ if (!annotations?.length) {
3142
+ return renderStatus;
3143
+ }
3144
+ annotations = this.filterInteractableAnnotationsForElement(element, annotations);
3145
+ if (!annotations?.length) {
3146
+ return renderStatus;
3147
+ }
3148
+ const targetId = this.getTargetId(viewport);
3149
+ const renderingEngine = viewport.getRenderingEngine();
3150
+ const styleSpecifier = {
3151
+ toolGroupId: this.toolGroupId,
3152
+ toolName: this.getToolName(),
3153
+ viewportId: enabledElement.viewport.id,
3154
+ };
3155
+ for (let i = 0; i < annotations.length; i++) {
3156
+ const annotation = annotations[i];
3157
+ const { annotationUID, data } = annotation;
3158
+ const { points, activeHandleIndex } = data.handles;
3159
+ const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
3160
+ styleSpecifier.annotationUID = annotationUID;
3161
+ const { color, lineWidth, lineDash, shadow } = this.getAnnotationStyle({
3162
+ annotation,
3163
+ styleSpecifier,
3164
+ });
3165
+ if (!data.cachedStats[targetId] ||
3166
+ data.cachedStats[targetId].unit == null) {
3167
+ data.cachedStats[targetId] = {
3168
+ length: null,
3169
+ width: null,
3170
+ unit: null,
3171
+ };
3172
+ this._calculateCachedStats(annotation, renderingEngine, enabledElement);
3173
+ }
3174
+ else if (annotation.invalidated) {
3175
+ this._throttledCalculateCachedStats(annotation, renderingEngine, enabledElement);
3176
+ }
3177
+ if (!viewport.getRenderingEngine()) {
3178
+ console.warn('Rendering Engine has been destroyed');
3179
+ return renderStatus;
3180
+ }
3181
+ let activeHandleCanvasCoords;
3182
+ if (!(0,_stateManagement_annotation_annotationVisibility__WEBPACK_IMPORTED_MODULE_7__.isAnnotationVisible)(annotationUID)) {
3183
+ continue;
3184
+ }
3185
+ if (!(0,_stateManagement_annotation_annotationLocking__WEBPACK_IMPORTED_MODULE_6__.isAnnotationLocked)(annotationUID) &&
3186
+ !this.editData &&
3187
+ activeHandleIndex !== null) {
3188
+ activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
3189
+ }
3190
+ if (activeHandleCanvasCoords) {
3191
+ const handleGroupUID = '0';
3192
+ (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_9__.drawHandles)(svgDrawingHelper, annotationUID, handleGroupUID, activeHandleCanvasCoords, {
3193
+ color,
3194
+ });
3195
+ }
3196
+ const dataId1 = `${annotationUID}-line-1`;
3197
+ const dataId2 = `${annotationUID}-line-2`;
3198
+ const lineUID = '0';
3199
+ (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_9__.drawLine)(svgDrawingHelper, annotationUID, lineUID, canvasCoordinates[0], canvasCoordinates[1], {
3200
+ color,
3201
+ lineDash,
3202
+ lineWidth,
3203
+ shadow,
3204
+ }, dataId1);
3205
+ const secondLineUID = '1';
3206
+ (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_9__.drawLine)(svgDrawingHelper, annotationUID, secondLineUID, canvasCoordinates[2], canvasCoordinates[3], {
3207
+ color,
3208
+ lineDash,
3209
+ lineWidth,
3210
+ shadow,
3211
+ }, dataId2);
3212
+ renderStatus = true;
3213
+ const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
3214
+ if (!options.visibility) {
3215
+ data.handles.textBox = {
3216
+ hasMoved: false,
3217
+ worldPosition: [0, 0, 0],
3218
+ worldBoundingBox: {
3219
+ topLeft: [0, 0, 0],
3220
+ topRight: [0, 0, 0],
3221
+ bottomLeft: [0, 0, 0],
3222
+ bottomRight: [0, 0, 0],
3223
+ },
3224
+ };
3225
+ continue;
3226
+ }
3227
+ const textLines = this.configuration.getTextLines(data, targetId);
3228
+ if (!textLines || textLines.length === 0) {
3229
+ continue;
3230
+ }
3231
+ let canvasTextBoxCoords;
3232
+ if (!data.handles.textBox.hasMoved) {
3233
+ canvasTextBoxCoords = (0,_utilities_drawing__WEBPACK_IMPORTED_MODULE_14__.getTextBoxCoordsCanvas)(canvasCoordinates);
3234
+ data.handles.textBox.worldPosition =
3235
+ viewport.canvasToWorld(canvasTextBoxCoords);
3236
+ }
3237
+ const textBoxPosition = viewport.worldToCanvas(data.handles.textBox.worldPosition);
3238
+ const textBoxUID = '1';
3239
+ const boundingBox = (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_9__.drawLinkedTextBox)(svgDrawingHelper, annotationUID, textBoxUID, textLines, textBoxPosition, canvasCoordinates, {}, options);
3240
+ const { x: left, y: top, width, height } = boundingBox;
3241
+ data.handles.textBox.worldBoundingBox = {
3242
+ topLeft: viewport.canvasToWorld([left, top]),
3243
+ topRight: viewport.canvasToWorld([left + width, top]),
3244
+ bottomLeft: viewport.canvasToWorld([left, top + height]),
3245
+ bottomRight: viewport.canvasToWorld([left + width, top + height]),
3246
+ };
3247
+ }
3248
+ return renderStatus;
3249
+ };
3250
+ this._movingLongAxisWouldPutItThroughShortAxis = (firstLineSegment, secondLineSegment) => {
3251
+ const vectorInSecondLineDirection = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.create */ .Zc.create();
3252
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.set */ .Zc.set(vectorInSecondLineDirection, secondLineSegment.end.x - secondLineSegment.start.x, secondLineSegment.end.y - secondLineSegment.start.y);
3253
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec2.normalize */ .Zc.normalize(vectorInSecondLineDirection, vectorInSecondLineDirection);
3254
+ const extendedSecondLineSegment = {
3255
+ start: {
3256
+ x: secondLineSegment.start.x - vectorInSecondLineDirection[0] * 10,
3257
+ y: secondLineSegment.start.y - vectorInSecondLineDirection[1] * 10,
3258
+ },
3259
+ end: {
3260
+ x: secondLineSegment.end.x + vectorInSecondLineDirection[0] * 10,
3261
+ y: secondLineSegment.end.y + vectorInSecondLineDirection[1] * 10,
3262
+ },
3263
+ };
3264
+ const proposedIntersectionPoint = _utilities_math_line__WEBPACK_IMPORTED_MODULE_13__.intersectLine([extendedSecondLineSegment.start.x, extendedSecondLineSegment.start.y], [extendedSecondLineSegment.end.x, extendedSecondLineSegment.end.y], [firstLineSegment.start.x, firstLineSegment.start.y], [firstLineSegment.end.x, firstLineSegment.end.y]);
3265
+ const wouldPutThroughShortAxis = !proposedIntersectionPoint;
3266
+ return wouldPutThroughShortAxis;
3267
+ };
3268
+ this._calculateCachedStats = (annotation, renderingEngine, enabledElement) => {
3269
+ const { data } = annotation;
3270
+ const { element } = enabledElement.viewport;
3271
+ const worldPos1 = data.handles.points[0];
3272
+ const worldPos2 = data.handles.points[1];
3273
+ const worldPos3 = data.handles.points[2];
3274
+ const worldPos4 = data.handles.points[3];
3275
+ const { cachedStats } = data;
3276
+ const targetIds = Object.keys(cachedStats);
3277
+ for (let i = 0; i < targetIds.length; i++) {
3278
+ const targetId = targetIds[i];
3279
+ const image = this.getTargetImageData(targetId);
3280
+ if (!image) {
3281
+ continue;
3282
+ }
3283
+ const { imageData, dimensions } = image;
3284
+ const index1 = transformWorldToIndex(imageData, worldPos1);
3285
+ const index2 = transformWorldToIndex(imageData, worldPos2);
3286
+ const index3 = transformWorldToIndex(imageData, worldPos3);
3287
+ const index4 = transformWorldToIndex(imageData, worldPos4);
3288
+ const handles1 = [index1, index2];
3289
+ const handles2 = [index3, index4];
3290
+ const { scale: scale1, unit: units1 } = (0,_utilities_getCalibratedUnits__WEBPACK_IMPORTED_MODULE_2__/* .getCalibratedLengthUnitsAndScale */ .Op)(image, handles1);
3291
+ const { scale: scale2, unit: units2 } = (0,_utilities_getCalibratedUnits__WEBPACK_IMPORTED_MODULE_2__/* .getCalibratedLengthUnitsAndScale */ .Op)(image, handles2);
3292
+ const dist1 = this._calculateLength(worldPos1, worldPos2) / scale1;
3293
+ const dist2 = this._calculateLength(worldPos3, worldPos4) / scale2;
3294
+ const length = dist1 > dist2 ? dist1 : dist2;
3295
+ const width = dist1 > dist2 ? dist2 : dist1;
3296
+ const unit = dist1 > dist2 ? units1 : units2;
3297
+ const widthUnit = dist1 > dist2 ? units2 : units1;
3298
+ this._isInsideVolume(index1, index2, index3, index4, dimensions)
3299
+ ? (this.isHandleOutsideImage = false)
3300
+ : (this.isHandleOutsideImage = true);
3301
+ cachedStats[targetId] = {
3302
+ length,
3303
+ width,
3304
+ unit,
3305
+ widthUnit,
3306
+ };
3307
+ }
3308
+ annotation.invalidated = false;
3309
+ (0,_stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_8__.triggerAnnotationModified)(annotation, element);
3310
+ return cachedStats;
3311
+ };
3312
+ this._isInsideVolume = (index1, index2, index3, index4, dimensions) => {
3313
+ return (_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.indexWithinDimensions(index1, dimensions) &&
3314
+ _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.indexWithinDimensions(index2, dimensions) &&
3315
+ _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.indexWithinDimensions(index3, dimensions) &&
3316
+ _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.indexWithinDimensions(index4, dimensions));
3317
+ };
3318
+ this._getSignedAngle = (vector1, vector2) => {
3319
+ return Math.atan2(vector1[0] * vector2[1] - vector1[1] * vector2[0], vector1[0] * vector2[0] + vector1[1] * vector2[1]);
3320
+ };
3321
+ this._throttledCalculateCachedStats = (0,_utilities_throttle__WEBPACK_IMPORTED_MODULE_4__/* ["default"] */ .A)(this._calculateCachedStats, 100, { trailing: true });
3322
+ }
3323
+ addNewAnnotation(evt) {
3324
+ const eventDetail = evt.detail;
3325
+ const { currentPoints, element } = eventDetail;
3326
+ const worldPos = currentPoints.world;
3327
+ const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.getEnabledElement)(element);
3328
+ const { viewport, renderingEngine } = enabledElement;
3329
+ this.isDrawing = true;
3330
+ const camera = viewport.getCamera();
3331
+ const { viewPlaneNormal, viewUp } = camera;
3332
+ const referencedImageId = this.getReferencedImageId(viewport, worldPos, viewPlaneNormal, viewUp);
3333
+ const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
3334
+ const annotation = {
3335
+ highlighted: true,
3336
+ invalidated: true,
3337
+ metadata: {
3338
+ toolName: this.getToolName(),
3339
+ viewPlaneNormal: [...viewPlaneNormal],
3340
+ viewUp: [...viewUp],
3341
+ FrameOfReferenceUID,
3342
+ referencedImageId,
3343
+ ...viewport.getViewReference({ points: [worldPos] }),
3344
+ },
3345
+ data: {
3346
+ handles: {
3347
+ points: [
3348
+ [...worldPos],
3349
+ [...worldPos],
3350
+ [...worldPos],
3351
+ [...worldPos],
3352
+ ],
3353
+ textBox: {
3354
+ hasMoved: false,
3355
+ worldPosition: [0, 0, 0],
3356
+ worldBoundingBox: {
3357
+ topLeft: [0, 0, 0],
3358
+ topRight: [0, 0, 0],
3359
+ bottomLeft: [0, 0, 0],
3360
+ bottomRight: [0, 0, 0],
3361
+ },
3362
+ },
3363
+ activeHandleIndex: null,
3364
+ },
3365
+ label: '',
3366
+ cachedStats: {},
3367
+ },
3368
+ };
3369
+ (0,_stateManagement_annotation_annotationState__WEBPACK_IMPORTED_MODULE_5__.addAnnotation)(annotation, element);
3370
+ const viewportIdsToRender = (0,_utilities_viewportFilters__WEBPACK_IMPORTED_MODULE_12__.getViewportIdsWithToolToRender)(element, this.getToolName());
3371
+ this.editData = {
3372
+ annotation,
3373
+ viewportIdsToRender,
3374
+ handleIndex: 1,
3375
+ movingTextBox: false,
3376
+ newAnnotation: true,
3377
+ hasMoved: false,
3378
+ };
3379
+ this._activateDraw(element);
3380
+ (0,_cursors_elementCursor__WEBPACK_IMPORTED_MODULE_15__.hideElementCursor)(element);
3381
+ evt.preventDefault();
3382
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_16__/* ["default"] */ .A)(viewportIdsToRender);
3383
+ return annotation;
3384
+ }
3385
+ _calculateLength(pos1, pos2) {
3386
+ const dx = pos1[0] - pos2[0];
3387
+ const dy = pos1[1] - pos2[1];
3388
+ const dz = pos1[2] - pos2[2];
3389
+ return Math.sqrt(dx * dx + dy * dy + dz * dz);
3390
+ }
3391
+ }
3392
+ function defaultGetTextLines(data, targetId) {
3393
+ const { cachedStats, label } = data;
3394
+ const { length, width, unit } = cachedStats[targetId];
3395
+ const textLines = [];
3396
+ if (label) {
3397
+ textLines.push(label);
3398
+ }
3399
+ if (length === undefined) {
3400
+ return textLines;
3401
+ }
3402
+ textLines.push(`L: ${_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.roundNumber(length)} ${unit || unit}`, `W: ${_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_1__.utilities.roundNumber(width)} ${unit}`);
3403
+ return textLines;
3404
+ }
3405
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (BidirectionalTool);
3406
+
3407
+
3408
+ /***/ }),
3409
+
3410
+ /***/ 67847:
3411
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3412
+
3413
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3414
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
3415
+ /* harmony export */ });
3416
+ /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81985);
3417
+ /* harmony import */ var _utilities_getCalibratedUnits__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4096);
3418
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(40230);
3419
+ /* harmony import */ var _stateManagement__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6802);
3420
+ /* harmony import */ var _stateManagement_annotation_annotationLocking__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2076);
3421
+ /* harmony import */ var _drawingSvg__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(89578);
3422
+ /* harmony import */ var _utilities_viewportFilters__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(60810);
3423
+ /* harmony import */ var _utilities_throttle__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(27730);
3424
+ /* harmony import */ var _utilities_drawing__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(66990);
3425
+ /* harmony import */ var _utilities_planar_getWorldWidthAndHeightFromCorners__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(35489);
3426
+ /* harmony import */ var _stateManagement_annotation_annotationVisibility__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(29601);
3427
+ /* harmony import */ var _cursors_elementCursor__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(7001);
3428
+ /* harmony import */ var _utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(58640);
3429
+ /* harmony import */ var _stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(44049);
3430
+ /* harmony import */ var _annotation_RectangleROITool__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(4010);
3431
+ /* harmony import */ var _utilities_viewport_isViewportPreScaled__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(18990);
3432
+ /* harmony import */ var _utilities_math_basic__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(73262);
3433
+ /* harmony import */ var _utilities_planar__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(93395);
3434
+ /* harmony import */ var _utilities_getPixelValueUnits__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(40634);
3435
+
3436
+
3437
+
3438
+
3439
+
3440
+
3441
+
3442
+
3443
+
3444
+
3445
+
3446
+
3447
+
3448
+
3449
+
3450
+
3451
+
3452
+
3453
+
3454
+ const { transformWorldToIndex } = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities;
3455
+ class RectangleROIStartEndThresholdTool extends _annotation_RectangleROITool__WEBPACK_IMPORTED_MODULE_14__/* ["default"] */ .A {
3456
+ constructor(toolProps = {}, defaultToolProps = {
3457
+ configuration: {
3458
+ storePointData: false,
3459
+ numSlicesToPropagate: 10,
3460
+ computePointsInsideVolume: false,
3461
+ getTextLines: defaultGetTextLines,
3462
+ statsCalculator: _utilities_math_basic__WEBPACK_IMPORTED_MODULE_16__.BasicStatsCalculator,
3463
+ showTextBox: false,
3464
+ },
3465
+ }) {
3466
+ super(toolProps, defaultToolProps);
3467
+ this.addNewAnnotation = (evt) => {
3468
+ const eventDetail = evt.detail;
3469
+ const { currentPoints, element } = eventDetail;
3470
+ const worldPos = currentPoints.world;
3471
+ const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getEnabledElement)(element);
3472
+ const { viewport, renderingEngine } = enabledElement;
3473
+ this.isDrawing = true;
3474
+ const camera = viewport.getCamera();
3475
+ const { viewPlaneNormal, viewUp } = camera;
3476
+ let referencedImageId, imageVolume, volumeId;
3477
+ if (viewport instanceof _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.StackViewport) {
3478
+ throw new Error('Stack Viewport Not implemented');
3479
+ }
3480
+ else {
3481
+ const targetId = this.getTargetId(viewport);
3482
+ volumeId = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.getVolumeId(targetId);
3483
+ imageVolume = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getVolume(volumeId);
3484
+ referencedImageId = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.getClosestImageId(imageVolume, worldPos, viewPlaneNormal);
3485
+ }
3486
+ const spacingInNormal = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.getSpacingInNormalDirection(imageVolume, viewPlaneNormal);
3487
+ const startCoord = this._getStartCoordinate(worldPos, viewPlaneNormal);
3488
+ const endCoord = this._getEndCoordinate(worldPos, spacingInNormal, viewPlaneNormal);
3489
+ const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
3490
+ const annotation = {
3491
+ highlighted: true,
3492
+ invalidated: true,
3493
+ metadata: {
3494
+ viewPlaneNormal: [...viewPlaneNormal],
3495
+ enabledElement,
3496
+ viewUp: [...viewUp],
3497
+ FrameOfReferenceUID,
3498
+ referencedImageId,
3499
+ toolName: this.getToolName(),
3500
+ volumeId,
3501
+ spacingInNormal,
3502
+ },
3503
+ data: {
3504
+ label: '',
3505
+ startCoordinate: startCoord,
3506
+ endCoordinate: endCoord,
3507
+ cachedStats: {
3508
+ pointsInVolume: [],
3509
+ projectionPoints: [],
3510
+ projectionPointsImageIds: [referencedImageId],
3511
+ statistics: [],
3512
+ },
3513
+ handles: {
3514
+ textBox: {
3515
+ hasMoved: false,
3516
+ worldPosition: [0, 0, 0],
3517
+ worldBoundingBox: {
3518
+ topLeft: [0, 0, 0],
3519
+ topRight: [0, 0, 0],
3520
+ bottomLeft: [0, 0, 0],
3521
+ bottomRight: [0, 0, 0],
3522
+ },
3523
+ },
3524
+ points: [
3525
+ [...worldPos],
3526
+ [...worldPos],
3527
+ [...worldPos],
3528
+ [...worldPos],
3529
+ ],
3530
+ activeHandleIndex: null,
3531
+ },
3532
+ labelmapUID: null,
3533
+ },
3534
+ };
3535
+ this._computeProjectionPoints(annotation, imageVolume);
3536
+ (0,_stateManagement__WEBPACK_IMPORTED_MODULE_3__/* .addAnnotation */ .lC)(annotation, element);
3537
+ const viewportIdsToRender = (0,_utilities_viewportFilters__WEBPACK_IMPORTED_MODULE_6__.getViewportIdsWithToolToRender)(element, this.getToolName());
3538
+ this.editData = {
3539
+ annotation,
3540
+ viewportIdsToRender,
3541
+ handleIndex: 3,
3542
+ newAnnotation: true,
3543
+ hasMoved: false,
3544
+ };
3545
+ this._activateDraw(element);
3546
+ (0,_cursors_elementCursor__WEBPACK_IMPORTED_MODULE_11__.hideElementCursor)(element);
3547
+ evt.preventDefault();
3548
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .A)(viewportIdsToRender);
3549
+ return annotation;
3550
+ };
3551
+ this._endCallback = (evt) => {
3552
+ const eventDetail = evt.detail;
3553
+ const { element } = eventDetail;
3554
+ const { annotation, viewportIdsToRender, newAnnotation, hasMoved } = this.editData;
3555
+ const { data } = annotation;
3556
+ if (newAnnotation && !hasMoved) {
3557
+ return;
3558
+ }
3559
+ data.handles.activeHandleIndex = null;
3560
+ this._deactivateModify(element);
3561
+ this._deactivateDraw(element);
3562
+ (0,_cursors_elementCursor__WEBPACK_IMPORTED_MODULE_11__.resetElementCursor)(element);
3563
+ const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getEnabledElement)(element);
3564
+ this.editData = null;
3565
+ this.isDrawing = false;
3566
+ if (this.isHandleOutsideImage &&
3567
+ this.configuration.preventHandleOutsideImage) {
3568
+ (0,_stateManagement__WEBPACK_IMPORTED_MODULE_3__/* .removeAnnotation */ .O8)(annotation.annotationUID);
3569
+ }
3570
+ const targetId = this.getTargetId(enabledElement.viewport);
3571
+ const imageVolume = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getVolume(targetId.split(/volumeId:|\?/)[1]);
3572
+ if (this.configuration.calculatePointsInsideVolume) {
3573
+ this._computePointsInsideVolume(annotation, targetId, imageVolume, enabledElement);
3574
+ }
3575
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_12__/* ["default"] */ .A)(viewportIdsToRender);
3576
+ if (newAnnotation) {
3577
+ (0,_stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_13__.triggerAnnotationCompleted)(annotation);
3578
+ }
3579
+ };
3580
+ this.renderAnnotation = (enabledElement, svgDrawingHelper) => {
3581
+ let renderStatus = false;
3582
+ const { viewport } = enabledElement;
3583
+ let annotations = (0,_stateManagement__WEBPACK_IMPORTED_MODULE_3__/* .getAnnotations */ .Rh)(this.getToolName(), viewport.element);
3584
+ if (!annotations?.length) {
3585
+ return renderStatus;
3586
+ }
3587
+ annotations = (0,_utilities_planar__WEBPACK_IMPORTED_MODULE_17__.filterAnnotationsWithinSamePlane)(annotations, viewport.getCamera());
3588
+ const styleSpecifier = {
3589
+ toolGroupId: this.toolGroupId,
3590
+ toolName: this.getToolName(),
3591
+ viewportId: enabledElement.viewport.id,
3592
+ };
3593
+ for (let i = 0; i < annotations.length; i++) {
3594
+ const annotation = annotations[i];
3595
+ const { annotationUID, data, metadata } = annotation;
3596
+ const { startCoordinate, endCoordinate } = data;
3597
+ const { points, activeHandleIndex } = data.handles;
3598
+ const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
3599
+ styleSpecifier.annotationUID = annotationUID;
3600
+ const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
3601
+ const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
3602
+ const color = this.getStyle('color', styleSpecifier, annotation);
3603
+ const focalPoint = viewport.getCamera().focalPoint;
3604
+ const viewplaneNormal = viewport.getCamera().viewPlaneNormal;
3605
+ let startCoord = startCoordinate;
3606
+ let endCoord = endCoordinate;
3607
+ if (Array.isArray(startCoordinate)) {
3608
+ startCoord = this._getCoordinateForViewplaneNormal(startCoord, viewplaneNormal);
3609
+ data.startCoordinate = startCoord;
3610
+ data.handles.points[0][this._getIndexOfCoordinatesForViewplaneNormal(viewplaneNormal)] = startCoord;
3611
+ data.startCoordinate = startCoord;
3612
+ data.handles.points[0][this._getIndexOfCoordinatesForViewplaneNormal(viewplaneNormal)] = startCoord;
3613
+ }
3614
+ if (Array.isArray(endCoordinate)) {
3615
+ endCoord = this._getCoordinateForViewplaneNormal(endCoord, viewplaneNormal);
3616
+ data.endCoordinate = endCoord;
3617
+ data.endCoordinate = endCoord;
3618
+ }
3619
+ const roundedStartCoord = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.roundToPrecision(startCoord);
3620
+ const roundedEndCoord = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.roundToPrecision(endCoord);
3621
+ const coord = this._getCoordinateForViewplaneNormal(focalPoint, viewplaneNormal);
3622
+ const roundedCoord = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.roundToPrecision(coord);
3623
+ if (roundedCoord < Math.min(roundedStartCoord, roundedEndCoord) ||
3624
+ roundedCoord > Math.max(roundedStartCoord, roundedEndCoord)) {
3625
+ continue;
3626
+ }
3627
+ if (annotation.invalidated) {
3628
+ this._throttledCalculateCachedStats(annotation, enabledElement);
3629
+ }
3630
+ let firstOrLastSlice = false;
3631
+ if (roundedCoord === roundedStartCoord ||
3632
+ roundedCoord === roundedEndCoord) {
3633
+ firstOrLastSlice = true;
3634
+ }
3635
+ if (!viewport.getRenderingEngine()) {
3636
+ console.warn('Rendering Engine has been destroyed');
3637
+ return renderStatus;
3638
+ }
3639
+ let activeHandleCanvasCoords;
3640
+ if (!(0,_stateManagement_annotation_annotationVisibility__WEBPACK_IMPORTED_MODULE_10__.isAnnotationVisible)(annotationUID)) {
3641
+ continue;
3642
+ }
3643
+ if (!(0,_stateManagement_annotation_annotationLocking__WEBPACK_IMPORTED_MODULE_4__.isAnnotationLocked)(annotationUID) &&
3644
+ !this.editData &&
3645
+ activeHandleIndex !== null &&
3646
+ firstOrLastSlice) {
3647
+ activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
3648
+ }
3649
+ if (activeHandleCanvasCoords) {
3650
+ const handleGroupUID = '0';
3651
+ (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_5__.drawHandles)(svgDrawingHelper, annotationUID, handleGroupUID, activeHandleCanvasCoords, {
3652
+ color,
3653
+ });
3654
+ }
3655
+ let lineDashToUse = lineDash;
3656
+ if (!firstOrLastSlice) {
3657
+ lineDashToUse = 2;
3658
+ }
3659
+ const rectangleUID = '0';
3660
+ (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_5__.drawRect)(svgDrawingHelper, annotationUID, rectangleUID, canvasCoordinates[0], canvasCoordinates[3], {
3661
+ color,
3662
+ lineDash: lineDashToUse,
3663
+ lineWidth,
3664
+ });
3665
+ renderStatus = true;
3666
+ if (this.configuration.showTextBox &&
3667
+ this.configuration.calculatePointsInsideVolume) {
3668
+ const options = this.getLinkedTextBoxStyle(styleSpecifier, annotation);
3669
+ if (!options.visibility) {
3670
+ data.handles.textBox = {
3671
+ hasMoved: false,
3672
+ worldPosition: [0, 0, 0],
3673
+ worldBoundingBox: {
3674
+ topLeft: [0, 0, 0],
3675
+ topRight: [0, 0, 0],
3676
+ bottomLeft: [0, 0, 0],
3677
+ bottomRight: [0, 0, 0],
3678
+ },
3679
+ };
3680
+ continue;
3681
+ }
3682
+ const textLines = this.configuration.getTextLines(data, { metadata });
3683
+ if (!textLines || textLines.length === 0) {
3684
+ continue;
3685
+ }
3686
+ if (!data.handles.textBox.hasMoved) {
3687
+ const canvasTextBoxCoords = (0,_utilities_drawing__WEBPACK_IMPORTED_MODULE_8__.getTextBoxCoordsCanvas)(canvasCoordinates);
3688
+ data.handles.textBox.worldPosition =
3689
+ viewport.canvasToWorld(canvasTextBoxCoords);
3690
+ }
3691
+ const textBoxPosition = viewport.worldToCanvas(data.handles.textBox.worldPosition);
3692
+ const textBoxUID = '1';
3693
+ const boundingBox = (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_5__.drawLinkedTextBox)(svgDrawingHelper, annotationUID, textBoxUID, textLines, textBoxPosition, canvasCoordinates, {}, options);
3694
+ const { x: left, y: top, width, height } = boundingBox;
3695
+ data.handles.textBox.worldBoundingBox = {
3696
+ topLeft: viewport.canvasToWorld([left, top]),
3697
+ topRight: viewport.canvasToWorld([left + width, top]),
3698
+ bottomLeft: viewport.canvasToWorld([left, top + height]),
3699
+ bottomRight: viewport.canvasToWorld([left + width, top + height]),
3700
+ };
3701
+ }
3702
+ }
3703
+ return renderStatus;
3704
+ };
3705
+ this._throttledCalculateCachedStats = (0,_utilities_throttle__WEBPACK_IMPORTED_MODULE_7__/* ["default"] */ .A)(this._calculateCachedStatsTool, 100, { trailing: true });
3706
+ }
3707
+ _computeProjectionPoints(annotation, imageVolume) {
3708
+ const { data, metadata } = annotation;
3709
+ const { viewPlaneNormal, spacingInNormal } = metadata;
3710
+ const { imageData } = imageVolume;
3711
+ const { startCoordinate, endCoordinate } = data;
3712
+ const { points } = data.handles;
3713
+ const startIJK = transformWorldToIndex(imageData, points[0]);
3714
+ const endIJK = transformWorldToIndex(imageData, points[0]);
3715
+ const startWorld = gl_matrix__WEBPACK_IMPORTED_MODULE_2__/* .vec3.create */ .eR.create();
3716
+ imageData.indexToWorldVec3(startIJK, startWorld);
3717
+ const endWorld = gl_matrix__WEBPACK_IMPORTED_MODULE_2__/* .vec3.create */ .eR.create();
3718
+ imageData.indexToWorldVec3(endIJK, endWorld);
3719
+ if (this._getIndexOfCoordinatesForViewplaneNormal(viewPlaneNormal) == 2) {
3720
+ startWorld[2] = startCoordinate;
3721
+ endWorld[2] = endCoordinate;
3722
+ }
3723
+ else if (this._getIndexOfCoordinatesForViewplaneNormal(viewPlaneNormal) == 0) {
3724
+ startWorld[0] = startCoordinate;
3725
+ endWorld[0] = endCoordinate;
3726
+ }
3727
+ else if (this._getIndexOfCoordinatesForViewplaneNormal(viewPlaneNormal) == 1) {
3728
+ startWorld[1] = startCoordinate;
3729
+ endWorld[1] = endCoordinate;
3730
+ }
3731
+ const distance = gl_matrix__WEBPACK_IMPORTED_MODULE_2__/* .vec3.distance */ .eR.distance(startWorld, endWorld);
3732
+ const newProjectionPoints = [];
3733
+ for (let dist = 0; dist < distance; dist += spacingInNormal) {
3734
+ newProjectionPoints.push(points.map((point) => {
3735
+ const newPoint = gl_matrix__WEBPACK_IMPORTED_MODULE_2__/* .vec3.create */ .eR.create();
3736
+ gl_matrix__WEBPACK_IMPORTED_MODULE_2__/* .vec3.scaleAndAdd */ .eR.scaleAndAdd(newPoint, point, viewPlaneNormal, dist);
3737
+ return Array.from(newPoint);
3738
+ }));
3739
+ }
3740
+ data.cachedStats.projectionPoints = newProjectionPoints;
3741
+ }
3742
+ _computePointsInsideVolume(annotation, targetId, imageVolume, enabledElement) {
3743
+ const { data, metadata } = annotation;
3744
+ const { viewPlaneNormal, viewUp } = metadata;
3745
+ const { viewport } = enabledElement;
3746
+ const projectionPoints = data.cachedStats.projectionPoints;
3747
+ const pointsInsideVolume = [[]];
3748
+ const image = this.getTargetImageData(targetId);
3749
+ const worldPos1 = data.handles.points[0];
3750
+ const worldPos2 = data.handles.points[3];
3751
+ const { worldWidth, worldHeight } = (0,_utilities_planar_getWorldWidthAndHeightFromCorners__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A)(viewPlaneNormal, viewUp, worldPos1, worldPos2);
3752
+ const measureInfo = (0,_utilities_getCalibratedUnits__WEBPACK_IMPORTED_MODULE_1__/* .getCalibratedLengthUnitsAndScale */ .Op)(image, data.habdles);
3753
+ const area = Math.abs(worldWidth * worldHeight) /
3754
+ (measureInfo.scale * measureInfo.scale);
3755
+ const modalityUnitOptions = {
3756
+ isPreScaled: (0,_utilities_viewport_isViewportPreScaled__WEBPACK_IMPORTED_MODULE_15__/* .isViewportPreScaled */ .u)(viewport, targetId),
3757
+ isSuvScaled: this.isSuvScaled(viewport, targetId, annotation.metadata.referencedImageId),
3758
+ };
3759
+ const modalityUnit = (0,_utilities_getPixelValueUnits__WEBPACK_IMPORTED_MODULE_18__/* .getPixelValueUnits */ .j)(metadata.Modality, annotation.metadata.referencedImageId, modalityUnitOptions);
3760
+ for (let i = 0; i < projectionPoints.length; i++) {
3761
+ if (!imageVolume) {
3762
+ continue;
3763
+ }
3764
+ const projectionPoint = projectionPoints[i][0];
3765
+ const { dimensions, imageData, voxelManager } = imageVolume;
3766
+ const worldPos1Index = transformWorldToIndex(imageData, worldPos1);
3767
+ const worldProjectionPointIndex = transformWorldToIndex(imageData, projectionPoint);
3768
+ const indexOfProjection = this._getIndexOfCoordinatesForViewplaneNormal(viewPlaneNormal);
3769
+ worldPos1Index[0] = Math.floor(worldPos1Index[0]);
3770
+ worldPos1Index[1] = Math.floor(worldPos1Index[1]);
3771
+ worldPos1Index[2] = Math.floor(worldPos1Index[2]);
3772
+ worldPos1Index[indexOfProjection] =
3773
+ worldProjectionPointIndex[indexOfProjection];
3774
+ const worldPos2Index = transformWorldToIndex(imageData, worldPos2);
3775
+ worldPos2Index[0] = Math.floor(worldPos2Index[0]);
3776
+ worldPos2Index[1] = Math.floor(worldPos2Index[1]);
3777
+ worldPos2Index[2] = Math.floor(worldPos2Index[2]);
3778
+ worldPos2Index[indexOfProjection] =
3779
+ worldProjectionPointIndex[indexOfProjection];
3780
+ if (this._isInsideVolume(worldPos1Index, worldPos2Index, dimensions)) {
3781
+ this.isHandleOutsideImage = false;
3782
+ const iMin = Math.min(worldPos1Index[0], worldPos2Index[0]);
3783
+ const iMax = Math.max(worldPos1Index[0], worldPos2Index[0]);
3784
+ const jMin = Math.min(worldPos1Index[1], worldPos2Index[1]);
3785
+ const jMax = Math.max(worldPos1Index[1], worldPos2Index[1]);
3786
+ const kMin = Math.min(worldPos1Index[2], worldPos2Index[2]);
3787
+ const kMax = Math.max(worldPos1Index[2], worldPos2Index[2]);
3788
+ const boundsIJK = [
3789
+ [iMin, iMax],
3790
+ [jMin, jMax],
3791
+ [kMin, kMax],
3792
+ ];
3793
+ const pointsInShape = voxelManager.forEach(this.configuration.statsCalculator.statsCallback, {
3794
+ boundsIJK,
3795
+ imageData,
3796
+ returnPoints: this.configuration.storePointData,
3797
+ });
3798
+ pointsInsideVolume.push(pointsInShape);
3799
+ }
3800
+ }
3801
+ const stats = this.configuration.statsCalculator.getStatistics();
3802
+ data.cachedStats.pointsInVolume = pointsInsideVolume;
3803
+ data.cachedStats.statistics = {
3804
+ Modality: metadata.Modality,
3805
+ area,
3806
+ mean: stats.mean?.value,
3807
+ stdDev: stats.stdDev?.value,
3808
+ max: stats.max?.value,
3809
+ statsArray: stats.array,
3810
+ areaUnit: measureInfo.areaUnit,
3811
+ modalityUnit,
3812
+ };
3813
+ }
3814
+ _calculateCachedStatsTool(annotation, enabledElement) {
3815
+ const data = annotation.data;
3816
+ const { viewport } = enabledElement;
3817
+ const { cachedStats } = data;
3818
+ const targetId = this.getTargetId(viewport);
3819
+ const imageVolume = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getVolume(targetId.split(/volumeId:|\?/)[1]);
3820
+ this._computeProjectionPoints(annotation, imageVolume);
3821
+ if (this.configuration.calculatePointsInsideVolume) {
3822
+ this._computePointsInsideVolume(annotation, targetId, imageVolume, enabledElement);
3823
+ }
3824
+ if (this.configuration.calculatePointsInsideVolume) {
3825
+ this._computePointsInsideVolume(annotation, targetId, imageVolume, enabledElement);
3826
+ }
3827
+ annotation.invalidated = false;
3828
+ (0,_stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_13__.triggerAnnotationModified)(annotation, viewport.element);
3829
+ return cachedStats;
3830
+ }
3831
+ _getStartCoordinate(worldPos, viewPlaneNormal) {
3832
+ const startPos = worldPos;
3833
+ const startCoord = this._getCoordinateForViewplaneNormal(startPos, viewPlaneNormal);
3834
+ return startCoord;
3835
+ }
3836
+ _getEndCoordinate(worldPos, spacingInNormal, viewPlaneNormal) {
3837
+ const numSlicesToPropagate = this.configuration.numSlicesToPropagate;
3838
+ const endPos = gl_matrix__WEBPACK_IMPORTED_MODULE_2__/* .vec3.create */ .eR.create();
3839
+ gl_matrix__WEBPACK_IMPORTED_MODULE_2__/* .vec3.scaleAndAdd */ .eR.scaleAndAdd(endPos, worldPos, viewPlaneNormal, numSlicesToPropagate * spacingInNormal);
3840
+ const endCoord = this._getCoordinateForViewplaneNormal(endPos, viewPlaneNormal);
3841
+ return endCoord;
3842
+ }
3843
+ _getIndexOfCoordinatesForViewplaneNormal(viewPlaneNormal) {
3844
+ const viewplaneNormalAbs = [
3845
+ Math.abs(viewPlaneNormal[0]),
3846
+ Math.abs(viewPlaneNormal[1]),
3847
+ Math.abs(viewPlaneNormal[2]),
3848
+ ];
3849
+ const indexOfDirection = viewplaneNormalAbs.indexOf(Math.max(...viewplaneNormalAbs));
3850
+ return indexOfDirection;
3851
+ }
3852
+ _getCoordinateForViewplaneNormal(pos, viewPlaneNormal) {
3853
+ const indexOfDirection = this._getIndexOfCoordinatesForViewplaneNormal(viewPlaneNormal);
3854
+ return pos[indexOfDirection];
3855
+ }
3856
+ }
3857
+ function defaultGetTextLines(data, _context = {}) {
3858
+ const cachedVolumeStats = data.cachedStats.statistics;
3859
+ const { area, mean, max, stdDev, areaUnit, modalityUnit } = cachedVolumeStats;
3860
+ if (mean === undefined) {
3861
+ return;
3862
+ }
3863
+ const textLines = [];
3864
+ textLines.push(`Area: ${_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.roundNumber(area)} ${areaUnit}`);
3865
+ textLines.push(`Mean: ${_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.roundNumber(mean)} ${modalityUnit}`);
3866
+ textLines.push(`Max: ${_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.roundNumber(max)} ${modalityUnit}`);
3867
+ textLines.push(`Std Dev: ${_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.roundNumber(stdDev)} ${modalityUnit}`);
3868
+ return textLines;
3869
+ }
3870
+ RectangleROIStartEndThresholdTool.toolName = 'RectangleROIStartEndThreshold';
3871
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (RectangleROIStartEndThresholdTool);
3872
+
3873
+
3874
+ /***/ }),
3875
+
3876
+ /***/ 40336:
3877
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
3878
+
3879
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3880
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
3881
+ /* harmony export */ });
3882
+ /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81985);
3883
+ /* harmony import */ var _stateManagement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6802);
3884
+ /* harmony import */ var _stateManagement_annotation_annotationLocking__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2076);
3885
+ /* harmony import */ var _drawingSvg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(89578);
3886
+ /* harmony import */ var _utilities_viewportFilters__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(60810);
3887
+ /* harmony import */ var _cursors_elementCursor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7001);
3888
+ /* harmony import */ var _utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(58640);
3889
+ /* harmony import */ var _stateManagement_annotation_annotationVisibility__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(29601);
3890
+ /* harmony import */ var _stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(44049);
3891
+ /* harmony import */ var _annotation_RectangleROITool__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(4010);
3892
+
3893
+
3894
+
3895
+
3896
+
3897
+
3898
+
3899
+
3900
+
3901
+
3902
+ class RectangleROIThresholdTool extends _annotation_RectangleROITool__WEBPACK_IMPORTED_MODULE_9__/* ["default"] */ .A {
3903
+ constructor(toolProps = {}, defaultToolProps = {
3904
+ supportedInteractionTypes: ['Mouse', 'Touch'],
3905
+ configuration: {
3906
+ shadow: true,
3907
+ preventHandleOutsideImage: false,
3908
+ },
3909
+ }) {
3910
+ super(toolProps, defaultToolProps);
3911
+ this.addNewAnnotation = (evt) => {
3912
+ const eventDetail = evt.detail;
3913
+ const { currentPoints, element } = eventDetail;
3914
+ const worldPos = currentPoints.world;
3915
+ const enabledElement = (0,_cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.getEnabledElement)(element);
3916
+ const { viewport, renderingEngine } = enabledElement;
3917
+ this.isDrawing = true;
3918
+ const camera = viewport.getCamera();
3919
+ const { viewPlaneNormal, viewUp } = camera;
3920
+ const targetId = this.getTargetId(viewport);
3921
+ let referencedImageId, volumeId;
3922
+ if (viewport instanceof _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.StackViewport) {
3923
+ referencedImageId = targetId.split('imageId:')[1];
3924
+ }
3925
+ else {
3926
+ volumeId = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.getVolumeId(targetId);
3927
+ const imageVolume = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.cache.getVolume(volumeId);
3928
+ referencedImageId = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.getClosestImageId(imageVolume, worldPos, viewPlaneNormal);
3929
+ }
3930
+ const FrameOfReferenceUID = viewport.getFrameOfReferenceUID();
3931
+ const annotation = {
3932
+ highlighted: true,
3933
+ invalidated: true,
3934
+ metadata: {
3935
+ viewPlaneNormal: [...viewPlaneNormal],
3936
+ enabledElement,
3937
+ viewUp: [...viewUp],
3938
+ FrameOfReferenceUID,
3939
+ referencedImageId,
3940
+ toolName: this.getToolName(),
3941
+ volumeId,
3942
+ },
3943
+ data: {
3944
+ label: '',
3945
+ handles: {
3946
+ textBox: {
3947
+ hasMoved: false,
3948
+ worldPosition: null,
3949
+ worldBoundingBox: null,
3950
+ },
3951
+ points: [
3952
+ [...worldPos],
3953
+ [...worldPos],
3954
+ [...worldPos],
3955
+ [...worldPos],
3956
+ ],
3957
+ activeHandleIndex: null,
3958
+ },
3959
+ segmentationId: null,
3960
+ },
3961
+ };
3962
+ (0,_stateManagement__WEBPACK_IMPORTED_MODULE_1__/* .addAnnotation */ .lC)(annotation, element);
3963
+ const viewportIdsToRender = (0,_utilities_viewportFilters__WEBPACK_IMPORTED_MODULE_4__.getViewportIdsWithToolToRender)(element, this.getToolName());
3964
+ this.editData = {
3965
+ annotation,
3966
+ viewportIdsToRender,
3967
+ handleIndex: 3,
3968
+ newAnnotation: true,
3969
+ hasMoved: false,
3970
+ };
3971
+ this._activateDraw(element);
3972
+ (0,_cursors_elementCursor__WEBPACK_IMPORTED_MODULE_5__.hideElementCursor)(element);
3973
+ evt.preventDefault();
3974
+ (0,_utilities_triggerAnnotationRenderForViewportIds__WEBPACK_IMPORTED_MODULE_6__/* ["default"] */ .A)(viewportIdsToRender);
3975
+ return annotation;
3976
+ };
3977
+ this.renderAnnotation = (enabledElement, svgDrawingHelper) => {
3978
+ let renderStatus = false;
3979
+ const { viewport } = enabledElement;
3980
+ const { element } = viewport;
3981
+ let annotations = (0,_stateManagement__WEBPACK_IMPORTED_MODULE_1__/* .getAnnotations */ .Rh)(this.getToolName(), element);
3982
+ if (!annotations?.length) {
3983
+ return renderStatus;
3984
+ }
3985
+ annotations = this.filterInteractableAnnotationsForElement(element, annotations);
3986
+ if (!annotations?.length) {
3987
+ return renderStatus;
3988
+ }
3989
+ const styleSpecifier = {
3990
+ toolGroupId: this.toolGroupId,
3991
+ toolName: this.getToolName(),
3992
+ viewportId: enabledElement.viewport.id,
3993
+ };
3994
+ for (let i = 0; i < annotations.length; i++) {
3995
+ const annotation = annotations[i];
3996
+ const { annotationUID, data } = annotation;
3997
+ const { points, activeHandleIndex } = data.handles;
3998
+ const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
3999
+ styleSpecifier.annotationUID = annotationUID;
4000
+ const lineWidth = this.getStyle('lineWidth', styleSpecifier, annotation);
4001
+ const lineDash = this.getStyle('lineDash', styleSpecifier, annotation);
4002
+ const color = this.getStyle('color', styleSpecifier, annotation);
4003
+ if (!viewport.getRenderingEngine()) {
4004
+ console.warn('Rendering Engine has been destroyed');
4005
+ return renderStatus;
4006
+ }
4007
+ (0,_stateManagement_annotation_helpers_state__WEBPACK_IMPORTED_MODULE_8__.triggerAnnotationModified)(annotation, element);
4008
+ let activeHandleCanvasCoords;
4009
+ if (!(0,_stateManagement_annotation_annotationVisibility__WEBPACK_IMPORTED_MODULE_7__.isAnnotationVisible)(annotationUID)) {
4010
+ continue;
4011
+ }
4012
+ if (!(0,_stateManagement_annotation_annotationLocking__WEBPACK_IMPORTED_MODULE_2__.isAnnotationLocked)(annotationUID) &&
4013
+ !this.editData &&
4014
+ activeHandleIndex !== null) {
4015
+ activeHandleCanvasCoords = [canvasCoordinates[activeHandleIndex]];
4016
+ }
4017
+ if (activeHandleCanvasCoords) {
4018
+ const handleGroupUID = '0';
4019
+ (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_3__.drawHandles)(svgDrawingHelper, annotationUID, handleGroupUID, activeHandleCanvasCoords, {
4020
+ color,
4021
+ });
4022
+ }
4023
+ const rectangleUID = '0';
4024
+ (0,_drawingSvg__WEBPACK_IMPORTED_MODULE_3__.drawRect)(svgDrawingHelper, annotationUID, rectangleUID, canvasCoordinates[0], canvasCoordinates[3], {
4025
+ color,
4026
+ lineDash,
4027
+ lineWidth,
4028
+ });
4029
+ renderStatus = true;
4030
+ }
4031
+ return renderStatus;
4032
+ };
4033
+ }
4034
+ }
4035
+ RectangleROIThresholdTool.toolName = 'RectangleROIThreshold';
4036
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (RectangleROIThresholdTool);
4037
+
4038
+
4039
+ /***/ }),
4040
+
4041
+ /***/ 64843:
4042
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4043
+
4044
+ __webpack_require__.r(__webpack_exports__);
4045
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4046
+ /* harmony export */ addContourSegmentationAnnotation: () => (/* reexport safe */ _addContourSegmentationAnnotation__WEBPACK_IMPORTED_MODULE_2__.V),
4047
+ /* harmony export */ areSameSegment: () => (/* reexport safe */ _areSameSegment__WEBPACK_IMPORTED_MODULE_0__.A),
4048
+ /* harmony export */ isContourSegmentationAnnotation: () => (/* reexport safe */ _isContourSegmentationAnnotation__WEBPACK_IMPORTED_MODULE_1__.A),
4049
+ /* harmony export */ removeContourSegmentationAnnotation: () => (/* reexport safe */ _removeContourSegmentationAnnotation__WEBPACK_IMPORTED_MODULE_3__.M)
4050
+ /* harmony export */ });
4051
+ /* harmony import */ var _areSameSegment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(62854);
4052
+ /* harmony import */ var _isContourSegmentationAnnotation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(78130);
4053
+ /* harmony import */ var _addContourSegmentationAnnotation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(85263);
4054
+ /* harmony import */ var _removeContourSegmentationAnnotation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(37354);
4055
+
4056
+
4057
+
4058
+
4059
+
4060
+
4061
+ /***/ }),
4062
+
4063
+ /***/ 13054:
4064
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4065
+
4066
+ __webpack_require__.r(__webpack_exports__);
4067
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4068
+ /* harmony export */ AnnotationToPointData: () => (/* reexport safe */ _AnnotationToPointData__WEBPACK_IMPORTED_MODULE_5__.A),
4069
+ /* harmony export */ acceptAutogeneratedInterpolations: () => (/* reexport safe */ _interpolation_acceptAutogeneratedInterpolations__WEBPACK_IMPORTED_MODULE_9__.A),
4070
+ /* harmony export */ areCoplanarContours: () => (/* reexport safe */ _areCoplanarContours__WEBPACK_IMPORTED_MODULE_0__.A),
4071
+ /* harmony export */ calculatePerimeter: () => (/* reexport safe */ _calculatePerimeter__WEBPACK_IMPORTED_MODULE_11__.A),
4072
+ /* harmony export */ contourFinder: () => (/* reexport safe */ _contourFinder__WEBPACK_IMPORTED_MODULE_1__.Ay),
4073
+ /* harmony export */ detectContourHoles: () => (/* reexport safe */ _detectContourHoles__WEBPACK_IMPORTED_MODULE_3__.A),
4074
+ /* harmony export */ findHandlePolylineIndex: () => (/* reexport safe */ _findHandlePolylineIndex__WEBPACK_IMPORTED_MODULE_10__.A),
4075
+ /* harmony export */ generateContourSetsFromLabelmap: () => (/* reexport safe */ _generateContourSetsFromLabelmap__WEBPACK_IMPORTED_MODULE_4__.d),
4076
+ /* harmony export */ getContourHolesDataCanvas: () => (/* reexport safe */ _getContourHolesDataCanvas__WEBPACK_IMPORTED_MODULE_7__.A),
4077
+ /* harmony export */ getContourHolesDataWorld: () => (/* reexport safe */ _getContourHolesDataWorld__WEBPACK_IMPORTED_MODULE_6__.A),
4078
+ /* harmony export */ getDeduplicatedVTKPolyDataPoints: () => (/* reexport safe */ _getDeduplicatedVTKPolyDataPoints__WEBPACK_IMPORTED_MODULE_2__.v),
4079
+ /* harmony export */ updateContourPolyline: () => (/* reexport safe */ _updateContourPolyline__WEBPACK_IMPORTED_MODULE_8__.A)
4080
+ /* harmony export */ });
4081
+ /* harmony import */ var _areCoplanarContours__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40825);
4082
+ /* harmony import */ var _contourFinder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(46228);
4083
+ /* harmony import */ var _getDeduplicatedVTKPolyDataPoints__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(37546);
4084
+ /* harmony import */ var _detectContourHoles__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(69814);
4085
+ /* harmony import */ var _generateContourSetsFromLabelmap__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(81688);
4086
+ /* harmony import */ var _AnnotationToPointData__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(29632);
4087
+ /* harmony import */ var _getContourHolesDataWorld__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(55659);
4088
+ /* harmony import */ var _getContourHolesDataCanvas__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(15451);
4089
+ /* harmony import */ var _updateContourPolyline__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(72967);
4090
+ /* harmony import */ var _interpolation_acceptAutogeneratedInterpolations__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(67192);
4091
+ /* harmony import */ var _findHandlePolylineIndex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(98013);
4092
+ /* harmony import */ var _calculatePerimeter__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(93843);
4093
+
4094
+
4095
+
4096
+
4097
+
4098
+
4099
+
4100
+
4101
+
4102
+
4103
+
4104
+
4105
+
4106
+
4107
+
4108
+ /***/ }),
4109
+
4110
+ /***/ 23566:
4111
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4112
+
4113
+ // ESM COMPAT FLAG
4114
+ __webpack_require__.r(__webpack_exports__);
4115
+
4116
+ // EXPORTS
4117
+ __webpack_require__.d(__webpack_exports__, {
4118
+ AnnotationMultiSlice: () => (/* reexport */ AnnotationMultiSlice/* default */.A),
4119
+ IslandRemoval: () => (/* reexport */ islandRemoval/* default */.A),
4120
+ annotationHydration: () => (/* reexport */ annotationHydration/* annotationHydration */.i),
4121
+ boundingBox: () => (/* reexport */ boundingBox),
4122
+ calibrateImageSpacing: () => (/* reexport */ calibrateImageSpacing/* default */.A),
4123
+ cine: () => (/* reexport */ cine),
4124
+ contourSegmentation: () => (/* reexport */ contourSegmentation),
4125
+ contours: () => (/* reexport */ contours),
4126
+ debounce: () => (/* reexport */ debounce/* default */.A),
4127
+ drawing: () => (/* reexport */ drawing),
4128
+ dynamicVolume: () => (/* reexport */ dynamicVolume),
4129
+ geometricSurfaceUtils: () => (/* reexport */ geometricSurfaceUtils),
4130
+ getAnnotationNearPoint: () => (/* reexport */ getAnnotationNearPoint/* getAnnotationNearPoint */.S),
4131
+ getAnnotationNearPointOnEnabledElement: () => (/* reexport */ getAnnotationNearPoint/* getAnnotationNearPointOnEnabledElement */.s),
4132
+ getCalibratedAspect: () => (/* reexport */ getCalibratedUnits/* getCalibratedAspect */.CQ),
4133
+ getCalibratedLengthUnitsAndScale: () => (/* reexport */ getCalibratedUnits/* getCalibratedLengthUnitsAndScale */.Op),
4134
+ getCalibratedProbeUnitsAndValue: () => (/* reexport */ getCalibratedUnits/* getCalibratedProbeUnitsAndValue */.Xw),
4135
+ getClosestImageIdForStackViewport: () => (/* reexport */ annotationHydration/* getClosestImageIdForStackViewport */.x),
4136
+ getPixelValueUnits: () => (/* reexport */ getPixelValueUnits/* getPixelValueUnits */.j),
4137
+ getPixelValueUnitsImageId: () => (/* reexport */ getPixelValueUnits/* getPixelValueUnitsImageId */.N),
4138
+ getSphereBoundsInfo: () => (/* reexport */ getSphereBoundsInfo/* getSphereBoundsInfo */.R),
4139
+ getViewportForAnnotation: () => (/* reexport */ getViewportForAnnotation/* default */.A),
4140
+ isObject: () => (/* reexport */ isObject/* default */.A),
4141
+ math: () => (/* reexport */ math),
4142
+ normalizeViewportPlane: () => (/* reexport */ normalizeViewportPlane/* default */.A),
4143
+ orientation: () => (/* reexport */ orientation_namespaceObject),
4144
+ planar: () => (/* reexport */ planar),
4145
+ planarFreehandROITool: () => (/* reexport */ planarFreehandROITool),
4146
+ pointInSurroundingSphereCallback: () => (/* reexport */ pointInSurroundingSphereCallback/* pointInSurroundingSphereCallback */.i),
4147
+ pointToString: () => (/* reexport */ pointToString/* pointToString */.l),
4148
+ polyDataUtils: () => (/* reexport */ utils),
4149
+ rectangleROITool: () => (/* reexport */ rectangleROITool),
4150
+ roundNumber: () => (/* binding */ roundNumber),
4151
+ segmentation: () => (/* reexport */ segmentation),
4152
+ stackContextPrefetch: () => (/* reexport */ stackPrefetch/* stackContextPrefetch */.N),
4153
+ stackPrefetch: () => (/* reexport */ stackPrefetch/* stackPrefetch */.S),
4154
+ throttle: () => (/* reexport */ throttle/* default */.A),
4155
+ touch: () => (/* reexport */ touch),
4156
+ triggerAnnotationRender: () => (/* reexport */ triggerAnnotationRender/* default */.A),
4157
+ triggerAnnotationRenderForToolGroupIds: () => (/* reexport */ triggerAnnotationRenderForToolGroupIds/* default */.A),
4158
+ triggerAnnotationRenderForViewportIds: () => (/* reexport */ triggerAnnotationRenderForViewportIds/* default */.A),
4159
+ triggerEvent: () => (/* reexport */ esm.triggerEvent),
4160
+ viewport: () => (/* reexport */ viewport),
4161
+ viewportFilters: () => (/* reexport */ viewportFilters),
4162
+ voi: () => (/* reexport */ voi)
4163
+ });
4164
+
4165
+ // NAMESPACE OBJECT: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/orientation/index.js
4166
+ var orientation_namespaceObject = {};
4167
+ __webpack_require__.r(orientation_namespaceObject);
4168
+ __webpack_require__.d(orientation_namespaceObject, {
4169
+ getOrientationStringLPS: () => (getOrientationStringLPS/* default */.A),
4170
+ invertOrientationStringLPS: () => (invertOrientationStringLPS/* default */.A)
4171
+ });
4172
+
4173
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/index.js
4174
+ var esm = __webpack_require__(81985);
4175
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/getAnnotationNearPoint.js
4176
+ var getAnnotationNearPoint = __webpack_require__(41293);
4177
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/debounce.js
4178
+ var debounce = __webpack_require__(52905);
4179
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/throttle.js
4180
+ var throttle = __webpack_require__(27730);
4181
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/isObject.js
4182
+ var isObject = __webpack_require__(45217);
4183
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/calibrateImageSpacing.js
4184
+ var calibrateImageSpacing = __webpack_require__(58271);
4185
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/getCalibratedUnits.js
4186
+ var getCalibratedUnits = __webpack_require__(4096);
4187
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/triggerAnnotationRenderForViewportIds.js
4188
+ var triggerAnnotationRenderForViewportIds = __webpack_require__(58640);
4189
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/triggerAnnotationRenderForToolGroupIds.js
4190
+ var triggerAnnotationRenderForToolGroupIds = __webpack_require__(94779);
4191
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/triggerAnnotationRender.js
4192
+ var triggerAnnotationRender = __webpack_require__(56069);
4193
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/getSphereBoundsInfo.js
4194
+ var getSphereBoundsInfo = __webpack_require__(4296);
4195
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/pointToString.js
4196
+ var pointToString = __webpack_require__(38726);
4197
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/AnnotationMultiSlice.js
4198
+ var AnnotationMultiSlice = __webpack_require__(16678);
4199
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/getViewportForAnnotation.js
4200
+ var getViewportForAnnotation = __webpack_require__(40133);
4201
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/annotationHydration.js
4202
+ var annotationHydration = __webpack_require__(64485);
4203
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contours/index.js
4204
+ var contours = __webpack_require__(13054);
4205
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/segmentation/index.js
4206
+ var segmentation = __webpack_require__(93759);
4207
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/drawing/index.js + 1 modules
4208
+ var drawing = __webpack_require__(66990);
4209
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/math/index.js
4210
+ var math = __webpack_require__(95527);
4211
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/planar/index.js + 3 modules
4212
+ var planar = __webpack_require__(93395);
4213
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/viewportFilters/index.js
4214
+ var viewportFilters = __webpack_require__(60810);
4215
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/orientation/getOrientationStringLPS.js
4216
+ var getOrientationStringLPS = __webpack_require__(7193);
4217
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/orientation/invertOrientationStringLPS.js
4218
+ var invertOrientationStringLPS = __webpack_require__(80405);
4219
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/orientation/index.js
4220
+
4221
+
4222
+
4223
+
4224
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/cine/index.js + 3 modules
4225
+ var cine = __webpack_require__(43488);
4226
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/boundingBox/index.js
4227
+ var boundingBox = __webpack_require__(72282);
4228
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/planarFreehandROITool/index.js
4229
+ var planarFreehandROITool = __webpack_require__(55002);
4230
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/rectangleROITool/index.js
4231
+ var rectangleROITool = __webpack_require__(74866);
4232
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/stackPrefetch/index.js + 2 modules
4233
+ var stackPrefetch = __webpack_require__(82295);
4234
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/viewport/index.js
4235
+ var viewport = __webpack_require__(19027);
4236
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/touch/index.js
4237
+ var touch = __webpack_require__(76260);
4238
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/dynamicVolume/index.js + 2 modules
4239
+ var dynamicVolume = __webpack_require__(74609);
4240
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/polyData/utils.js
4241
+ var utils = __webpack_require__(32994);
4242
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/voi/index.js + 4 modules
4243
+ var voi = __webpack_require__(93575);
4244
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/contourSegmentation/index.js
4245
+ var contourSegmentation = __webpack_require__(64843);
4246
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/pointInSurroundingSphereCallback.js
4247
+ var pointInSurroundingSphereCallback = __webpack_require__(10261);
4248
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/normalizeViewportPlane.js
4249
+ var normalizeViewportPlane = __webpack_require__(27963);
4250
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/segmentation/islandRemoval.js
4251
+ var islandRemoval = __webpack_require__(67912);
4252
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/getPixelValueUnits.js
4253
+ var getPixelValueUnits = __webpack_require__(40634);
4254
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/geometricSurfaceUtils.js
4255
+ var geometricSurfaceUtils = __webpack_require__(5565);
4256
+ ;// CONCATENATED MODULE: ../../../node_modules/@cornerstonejs/tools/dist/esm/utilities/index.js
4257
+
4258
+
4259
+
4260
+
4261
+
4262
+
4263
+
4264
+
4265
+
4266
+
4267
+
4268
+
4269
+
4270
+
4271
+
4272
+
4273
+
4274
+
4275
+
4276
+
4277
+
4278
+
4279
+
4280
+
4281
+
4282
+
4283
+
4284
+
4285
+
4286
+
4287
+
4288
+
4289
+
4290
+
4291
+ const roundNumber = esm.utilities.roundNumber;
4292
+
4293
+
4294
+
4295
+
4296
+
4297
+
4298
+
4299
+ /***/ }),
4300
+
4301
+ /***/ 93759:
4302
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4303
+
4304
+ __webpack_require__.r(__webpack_exports__);
4305
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4306
+ /* harmony export */ IslandRemoval: () => (/* reexport safe */ _islandRemoval__WEBPACK_IMPORTED_MODULE_21__.A),
4307
+ /* harmony export */ LabelmapMemo: () => (/* reexport module object */ _createLabelmapMemo__WEBPACK_IMPORTED_MODULE_20__),
4308
+ /* harmony export */ VolumetricCalculator: () => (/* reexport safe */ _VolumetricCalculator__WEBPACK_IMPORTED_MODULE_8__.A),
4309
+ /* harmony export */ computeStackLabelmapFromVolume: () => (/* reexport safe */ _stateManagement_segmentation_helpers_computeStackLabelmapFromVolume__WEBPACK_IMPORTED_MODULE_25__._),
4310
+ /* harmony export */ computeVolumeLabelmapFromStack: () => (/* reexport safe */ _stateManagement_segmentation_helpers_computeVolumeLabelmapFromStack__WEBPACK_IMPORTED_MODULE_26__.a),
4311
+ /* harmony export */ contourAndFindLargestBidirectional: () => (/* reexport safe */ _contourAndFindLargestBidirectional__WEBPACK_IMPORTED_MODULE_10__.A),
4312
+ /* harmony export */ createBidirectionalToolData: () => (/* reexport safe */ _createBidirectionalToolData__WEBPACK_IMPORTED_MODULE_11__.A),
4313
+ /* harmony export */ createLabelmapVolumeForViewport: () => (/* reexport safe */ _createLabelmapVolumeForViewport__WEBPACK_IMPORTED_MODULE_3__.A),
4314
+ /* harmony export */ createMergedLabelmapForIndex: () => (/* reexport safe */ _createMergedLabelmapForIndex__WEBPACK_IMPORTED_MODULE_2__.A),
4315
+ /* harmony export */ floodFill: () => (/* reexport safe */ _floodFill__WEBPACK_IMPORTED_MODULE_5__.A),
4316
+ /* harmony export */ getBrushSizeForToolGroup: () => (/* reexport safe */ _brushSizeForToolGroup__WEBPACK_IMPORTED_MODULE_6__.A),
4317
+ /* harmony export */ getBrushThresholdForToolGroup: () => (/* reexport safe */ _brushThresholdForToolGroup__WEBPACK_IMPORTED_MODULE_7__.Q),
4318
+ /* harmony export */ getBrushToolInstances: () => (/* reexport safe */ _getBrushToolInstances__WEBPACK_IMPORTED_MODULE_18__.n),
4319
+ /* harmony export */ getHoveredContourSegmentationAnnotation: () => (/* reexport safe */ _getHoveredContourSegmentationAnnotation__WEBPACK_IMPORTED_MODULE_17__.L),
4320
+ /* harmony export */ getOrCreateSegmentationVolume: () => (/* reexport safe */ _getOrCreateSegmentationVolume__WEBPACK_IMPORTED_MODULE_22__.A),
4321
+ /* harmony export */ getSegmentIndexAtLabelmapBorder: () => (/* reexport safe */ _getSegmentIndexAtLabelmapBorder__WEBPACK_IMPORTED_MODULE_16__.T),
4322
+ /* harmony export */ getSegmentIndexAtWorldPoint: () => (/* reexport safe */ _getSegmentIndexAtWorldPoint__WEBPACK_IMPORTED_MODULE_15__.hX),
4323
+ /* harmony export */ getStatistics: () => (/* reexport safe */ _getStatistics__WEBPACK_IMPORTED_MODULE_23__.A),
4324
+ /* harmony export */ getUniqueSegmentIndices: () => (/* reexport safe */ _getUniqueSegmentIndices__WEBPACK_IMPORTED_MODULE_14__.O),
4325
+ /* harmony export */ growCut: () => (/* reexport module object */ _growCut__WEBPACK_IMPORTED_MODULE_19__),
4326
+ /* harmony export */ invalidateBrushCursor: () => (/* reexport safe */ _invalidateBrushCursor__WEBPACK_IMPORTED_MODULE_13__.E),
4327
+ /* harmony export */ rectangleROIThresholdVolumeByRange: () => (/* reexport safe */ _rectangleROIThresholdVolumeByRange__WEBPACK_IMPORTED_MODULE_1__.A),
4328
+ /* harmony export */ segmentContourAction: () => (/* reexport safe */ _segmentContourAction__WEBPACK_IMPORTED_MODULE_12__.A),
4329
+ /* harmony export */ setBrushSizeForToolGroup: () => (/* reexport safe */ _brushSizeForToolGroup__WEBPACK_IMPORTED_MODULE_6__.M),
4330
+ /* harmony export */ setBrushThresholdForToolGroup: () => (/* reexport safe */ _brushThresholdForToolGroup__WEBPACK_IMPORTED_MODULE_7__.K),
4331
+ /* harmony export */ thresholdSegmentationByRange: () => (/* reexport safe */ _thresholdSegmentationByRange__WEBPACK_IMPORTED_MODULE_9__.A),
4332
+ /* harmony export */ thresholdVolumeByRange: () => (/* reexport safe */ _thresholdVolumeByRange__WEBPACK_IMPORTED_MODULE_0__.A),
4333
+ /* harmony export */ triggerSegmentationRender: () => (/* reexport safe */ _stateManagement_segmentation_SegmentationRenderingEngine__WEBPACK_IMPORTED_MODULE_4__.h6),
4334
+ /* harmony export */ triggerSegmentationRenderBySegmentationId: () => (/* reexport safe */ _stateManagement_segmentation_SegmentationRenderingEngine__WEBPACK_IMPORTED_MODULE_4__.fy),
4335
+ /* harmony export */ validateLabelmap: () => (/* reexport module object */ _validateLabelmap__WEBPACK_IMPORTED_MODULE_24__)
4336
+ /* harmony export */ });
4337
+ /* harmony import */ var _thresholdVolumeByRange__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8582);
4338
+ /* harmony import */ var _rectangleROIThresholdVolumeByRange__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(52323);
4339
+ /* harmony import */ var _createMergedLabelmapForIndex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4334);
4340
+ /* harmony import */ var _createLabelmapVolumeForViewport__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(97492);
4341
+ /* harmony import */ var _stateManagement_segmentation_SegmentationRenderingEngine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(24917);
4342
+ /* harmony import */ var _floodFill__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(84882);
4343
+ /* harmony import */ var _brushSizeForToolGroup__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(17014);
4344
+ /* harmony import */ var _brushThresholdForToolGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(49492);
4345
+ /* harmony import */ var _VolumetricCalculator__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(68915);
4346
+ /* harmony import */ var _thresholdSegmentationByRange__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(73706);
4347
+ /* harmony import */ var _contourAndFindLargestBidirectional__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(35271);
4348
+ /* harmony import */ var _createBidirectionalToolData__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(14514);
4349
+ /* harmony import */ var _segmentContourAction__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(22592);
4350
+ /* harmony import */ var _invalidateBrushCursor__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(35706);
4351
+ /* harmony import */ var _getUniqueSegmentIndices__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(25758);
4352
+ /* harmony import */ var _getSegmentIndexAtWorldPoint__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(71751);
4353
+ /* harmony import */ var _getSegmentIndexAtLabelmapBorder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(46507);
4354
+ /* harmony import */ var _getHoveredContourSegmentationAnnotation__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(20527);
4355
+ /* harmony import */ var _getBrushToolInstances__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(14957);
4356
+ /* harmony import */ var _growCut__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(97445);
4357
+ /* harmony import */ var _createLabelmapMemo__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(24778);
4358
+ /* harmony import */ var _islandRemoval__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(67912);
4359
+ /* harmony import */ var _getOrCreateSegmentationVolume__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(30722);
4360
+ /* harmony import */ var _getStatistics__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(84978);
4361
+ /* harmony import */ var _validateLabelmap__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(21345);
4362
+ /* harmony import */ var _stateManagement_segmentation_helpers_computeStackLabelmapFromVolume__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(93690);
4363
+ /* harmony import */ var _stateManagement_segmentation_helpers_computeVolumeLabelmapFromStack__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(6994);
4364
+
4365
+
4366
+
4367
+
4368
+
4369
+
4370
+
4371
+
4372
+
4373
+
4374
+
4375
+
4376
+
4377
+
4378
+
4379
+
4380
+
4381
+
4382
+
4383
+
4384
+
4385
+
4386
+
4387
+
4388
+
4389
+
4390
+
4391
+
4392
+
4393
+
4394
+ /***/ }),
4395
+
4396
+ /***/ 64063:
4397
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4398
+
4399
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4400
+ /* harmony export */ Dm: () => (/* binding */ setCachedSegmentIndices),
4401
+ /* harmony export */ HM: () => (/* binding */ setSegmentationDirty),
4402
+ /* harmony export */ Q5: () => (/* binding */ getVoxelOverlap),
4403
+ /* harmony export */ R1: () => (/* binding */ getCachedSegmentIndices),
4404
+ /* harmony export */ zf: () => (/* binding */ processVolumes)
4405
+ /* harmony export */ });
4406
+ /* unused harmony export setSegmentationClean */
4407
+ /* harmony import */ var _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(81985);
4408
+ /* harmony import */ var _boundingBox_getBoundingBoxAroundShape__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(87063);
4409
+
4410
+
4411
+ const equalsCheck = (a, b) => {
4412
+ return JSON.stringify(a) === JSON.stringify(b);
4413
+ };
4414
+ function getVoxelOverlap(imageData, dimensions, voxelSpacing, voxelCenter) {
4415
+ const halfSpacingX = voxelSpacing[0] / 2;
4416
+ const halfSpacingY = voxelSpacing[1] / 2;
4417
+ const halfSpacingZ = voxelSpacing[2] / 2;
4418
+ const voxelCornersIJK = new Array(8);
4419
+ voxelCornersIJK[0] = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.transformWorldToIndex(imageData, [
4420
+ voxelCenter[0] - halfSpacingX,
4421
+ voxelCenter[1] - halfSpacingY,
4422
+ voxelCenter[2] - halfSpacingZ,
4423
+ ]);
4424
+ const offsets = [
4425
+ [1, -1, -1],
4426
+ [-1, 1, -1],
4427
+ [1, 1, -1],
4428
+ [-1, -1, 1],
4429
+ [1, -1, 1],
4430
+ [-1, 1, 1],
4431
+ [1, 1, 1],
4432
+ ];
4433
+ for (let i = 0; i < 7; i++) {
4434
+ const [xOff, yOff, zOff] = offsets[i];
4435
+ voxelCornersIJK[i + 1] = _cornerstonejs_core__WEBPACK_IMPORTED_MODULE_0__.utilities.transformWorldToIndex(imageData, [
4436
+ voxelCenter[0] + xOff * halfSpacingX,
4437
+ voxelCenter[1] + yOff * halfSpacingY,
4438
+ voxelCenter[2] + zOff * halfSpacingZ,
4439
+ ]);
4440
+ }
4441
+ return (0,_boundingBox_getBoundingBoxAroundShape__WEBPACK_IMPORTED_MODULE_1__/* .getBoundingBoxAroundShapeIJK */ .g)(voxelCornersIJK, dimensions);
4442
+ }
4443
+ function processVolumes(segmentationVolume, thresholdVolumeInformation) {
4444
+ const { spacing: segmentationSpacing } = segmentationVolume;
4445
+ const scalarDataLength = segmentationVolume.voxelManager.getScalarDataLength();
4446
+ const volumeInfoList = [];
4447
+ let baseVolumeIdx = 0;
4448
+ for (let i = 0; i < thresholdVolumeInformation.length; i++) {
4449
+ const { imageData, spacing, dimensions, voxelManager } = thresholdVolumeInformation[i].volume;
4450
+ const volumeSize = thresholdVolumeInformation[i].volume.voxelManager.getScalarDataLength();
4451
+ if (volumeSize === scalarDataLength &&
4452
+ equalsCheck(spacing, segmentationSpacing)) {
4453
+ baseVolumeIdx = i;
4454
+ }
4455
+ const lower = thresholdVolumeInformation[i].lower;
4456
+ const upper = thresholdVolumeInformation[i].upper;
4457
+ volumeInfoList.push({
4458
+ imageData,
4459
+ lower,
4460
+ upper,
4461
+ spacing,
4462
+ dimensions,
4463
+ volumeSize,
4464
+ voxelManager,
4465
+ });
4466
+ }
4467
+ return {
4468
+ volumeInfoList,
4469
+ baseVolumeIdx,
4470
+ };
4471
+ }
4472
+ const segmentIndicesCache = new Map();
4473
+ const setSegmentationDirty = (segmentationId) => {
4474
+ const cached = segmentIndicesCache.get(segmentationId);
4475
+ if (cached) {
4476
+ cached.isDirty = true;
4477
+ }
4478
+ };
4479
+ const setSegmentationClean = (segmentationId) => {
4480
+ const cached = segmentIndicesCache.get(segmentationId);
4481
+ if (cached) {
4482
+ cached.isDirty = false;
4483
+ }
4484
+ };
4485
+ const getCachedSegmentIndices = (segmentationId) => {
4486
+ const cached = segmentIndicesCache.get(segmentationId);
4487
+ if (cached && !cached.isDirty) {
4488
+ return cached.indices;
4489
+ }
4490
+ return null;
4491
+ };
4492
+ const setCachedSegmentIndices = (segmentationId, indices) => {
4493
+ segmentIndicesCache.set(segmentationId, { indices, isDirty: false });
4494
+ };
4495
+
4496
+
4497
+ /***/ }),
4498
+
4499
+ /***/ 28802:
4500
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
4501
+
4502
+ __webpack_require__.r(__webpack_exports__);
4503
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4504
+ /* harmony export */ Colorbar: () => (/* reexport safe */ _Colorbar__WEBPACK_IMPORTED_MODULE_1__.P),
4505
+ /* harmony export */ Enums: () => (/* reexport module object */ _enums__WEBPACK_IMPORTED_MODULE_0__),
4506
+ /* harmony export */ ViewportColorbar: () => (/* reexport safe */ _ViewportColorbar__WEBPACK_IMPORTED_MODULE_2__.b)
4507
+ /* harmony export */ });
4508
+ /* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(51807);
4509
+ /* harmony import */ var _Colorbar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4848);
4510
+ /* harmony import */ var _ViewportColorbar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(91994);
4511
+
4512
+
4513
+
4514
+
4515
+
4516
+
4517
+ /***/ })
4518
+
4519
+ }]);