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

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 (54) hide show
  1. package/dist/1568.bundle.af4308b321dfab0445e6.js +6562 -0
  2. package/dist/{1919.bundle.fae108d3c6ad35ed05ae.js → 1919.bundle.a77f0f2b153cfb82b2b1.js} +8 -4
  3. package/dist/{2701.bundle.c9ea5a2bd0df31dd3aaa.js → 2701.bundle.1ebadde62fe950c7eea9.js} +10 -6
  4. package/dist/3480.bundle.a59925e9b05e17947b61.js +7495 -0
  5. package/dist/{3677.bundle.22ecea02fae99fc4b073.js → 3677.bundle.4a319db2fd495efa4564.js} +1648 -1654
  6. package/dist/{5770.bundle.700382010763de7c58fd.js → 4113.bundle.47c0f208ee01c2b6817a.js} +30 -76
  7. package/dist/{4202.bundle.add83801fbc8227d551b.js → 4202.bundle.a0d8fc27d1aa6f2bfda5.js} +1 -1
  8. package/dist/{4526.bundle.bf1047785c90ef0a9fec.js → 4526.bundle.ba9f06ec267e04b34263.js} +2 -2
  9. package/dist/{99.bundle.f7e8de6d86029ec75605.js → 4675.bundle.c2ca131cf6699bea0b10.js} +967 -2
  10. package/dist/4743.bundle.dadb9e009fdf0397d91d.js +6634 -0
  11. package/dist/{4759.bundle.0d60078f58f5a56c0157.js → 4759.bundle.0ef78b737c7578414046.js} +4 -0
  12. package/dist/{2236.bundle.2fbf9a607e380f3bdd7f.js → 4789.bundle.7a6308b116a7cf7ebad7.js} +22327 -22350
  13. package/dist/{4991.bundle.aa561005b9bff1f391af.js → 4991.bundle.897fe8cb1e85dbf31543.js} +4 -0
  14. package/dist/5258.bundle.f95ab2e02467a734bdb6.js +4519 -0
  15. package/dist/{5915.bundle.84b8c2aa4d4a8c7e40a2.js → 5341.bundle.2f963b49a4856e342cd1.js} +48327 -48879
  16. package/dist/{5674.bundle.05e639d0871778c8093a.js → 5674.bundle.d3ba8c0c2071e8a251e1.js} +4 -0
  17. package/dist/{5692.bundle.22ae2ac093b6d6b65a6e.js → 5692.bundle.9d06652645b36fc44770.js} +8 -8
  18. package/dist/{573.bundle.ae0bd4f3e1f4eac8ae43.js → 573.bundle.9549b3f7fa44438654f0.js} +1 -1
  19. package/dist/{8888.bundle.f6a648dc743772c89787.js → 6139.bundle.12d9035382cda028683b.js} +26538 -32458
  20. package/dist/{6201.bundle.11e6c535543d13b0bb98.js → 6201.bundle.3a6a86b85aaf7e86ac2d.js} +2 -2
  21. package/dist/{6341.bundle.5e868cc5104bc834fcbc.js → 6341.bundle.00414d6bd536ea41ea9f.js} +2 -2
  22. package/dist/{5038.bundle.790dfe509bc9841701b0.js → 6727.bundle.1fe4eada38ddd314a5ef.js} +4022 -11619
  23. package/dist/{6734.bundle.1a6cfb006f9a16963b0d.js → 6734.bundle.4e6ffdb7c039ba79ab6f.js} +1 -1
  24. package/dist/6752.bundle.e33e02dd8f006be51464.js +2249 -0
  25. package/dist/{7197.bundle.3503d1951304cac940fa.js → 7197.bundle.5b55e44c5e255ca7aa21.js} +9 -11
  26. package/dist/{8008.bundle.74e51bdb02ff5d264f50.js → 8008.bundle.b96dbf7f4df938a02b58.js} +3 -8
  27. package/dist/{810.bundle.342fc8fac8ae665558c6.js → 810.bundle.13891afc73aaeb8f8c66.js} +6 -6
  28. package/dist/{8558.bundle.56d667a6969a60bab102.js → 8558.bundle.e6ca98d86ec93de25d83.js} +5 -1
  29. package/dist/{870.bundle.26a075bb828c43c13794.js → 870.bundle.498565fab3be43d28d22.js} +9 -5
  30. package/dist/8834.bundle.88696f3afc37982b4273.js +14581 -0
  31. package/dist/{9026.bundle.90271a421048d1adc3db.js → 9026.bundle.5c5a6321ac688860691e.js} +6 -6
  32. package/dist/{9072.bundle.49293623f9ed4582eeeb.js → 9072.bundle.5c3b49ba4438226f094a.js} +30 -23
  33. package/dist/{9551.bundle.44d1426054e46cf5d673.js → 9551.bundle.14016005a3d8d6a26d79.js} +3 -8
  34. package/dist/{9862.bundle.a4ccc41bcff91a46d37e.js → 9862.bundle.6676f8d8c332a3a865e8.js} +2 -2
  35. package/dist/{9890.bundle.07483064f31feb5718a4.js → 9890.bundle.99b350df619ebee1e5d0.js} +2 -2
  36. package/dist/{app.bundle.3dc9aa5b6077224cc394.js → app.bundle.4715d739479984284c82.js} +53416 -52872
  37. package/dist/app.bundle.css +2 -2
  38. package/dist/{polySeg.bundle.d41f5224f4efc124505a.js → compute.bundle.fa052dcf2ef82b4950ad.js} +4 -3
  39. package/dist/{histogram-worker.bundle.6b0dbbdb168d711efad4.js → histogram-worker.bundle.986106c30f091f2cef47.js} +2 -1
  40. package/dist/index.html +1 -1
  41. package/dist/polySeg.bundle.a2f585d3ac3985fc5fbe.js +250 -0
  42. package/dist/{suv-peak-worker.bundle.4ca63044b76f51350d34.js → suv-peak-worker.bundle.e20ead81391fa6e2b7d5.js} +6 -5
  43. package/dist/sw.js +1 -1
  44. package/package.json +19 -19
  45. package/dist/2045.bundle.aaa10dff6d93bec47a45.js +0 -9708
  46. package/dist/6896.bundle.ca9b905abe733f279387.js +0 -7147
  47. /package/dist/{213.bundle.a98935570805e4a7b9b2.js → 213.bundle.b43c0a383eaebcfd6e17.js} +0 -0
  48. /package/dist/{2424.bundle.4f1eeae6a8f248dd34c1.js → 2424.bundle.bcd4f7aaceafe1eddf6c.js} +0 -0
  49. /package/dist/{2825.bundle.a9ed7e8b46a92a157797.js → 2825.bundle.c29d253e00fbead1a727.js} +0 -0
  50. /package/dist/{4834.bundle.750ec176d0ef84772b0a.js → 4834.bundle.047270ec0b81a24761b2.js} +0 -0
  51. /package/dist/{6027.bundle.32be836eef7308434394.js → 6027.bundle.0ef386fe3d24d22f9ed9.js} +0 -0
  52. /package/dist/{7955.bundle.eba45d4238f7e762545d.js → 7955.bundle.5fb99517b47262885f79.js} +0 -0
  53. /package/dist/{8228.bundle.4bcb42b49355447ef23c.js → 8228.bundle.c5a4f074986e66f8d2bf.js} +0 -0
  54. /package/dist/{8259.bundle.39723f9c04717f80687e.js → 8259.bundle.0ae4ee344b311a470d95.js} +0 -0
@@ -0,0 +1,2249 @@
1
+ "use strict";
2
+ (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[6752],{
3
+
4
+ /***/ 5057:
5
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
6
+
7
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8
+ /* harmony export */ A: () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)
9
+ /* harmony export */ });
10
+ /* harmony import */ var _rendering_now__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(53586);
11
+ /* harmony import */ var _rendering_renderColorImage__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(48080);
12
+ /* harmony import */ var _rendering_renderGrayscaleImage__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(92885);
13
+ /* harmony import */ var _rendering_renderPseudoColorImage__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(71209);
14
+
15
+
16
+
17
+
18
+ /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(enabledElement, invalidated) {
19
+ const image = enabledElement.image;
20
+ if (!enabledElement.canvas || !enabledElement.image) {
21
+ return;
22
+ }
23
+ const start = (0,_rendering_now__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)();
24
+ image.stats = {
25
+ lastGetPixelDataTime: -1.0,
26
+ lastStoredPixelDataToCanvasImageDataTime: -1.0,
27
+ lastPutImageDataTime: -1.0,
28
+ lastRenderTime: -1.0,
29
+ lastLutGenerateTime: -1.0,
30
+ };
31
+ if (image) {
32
+ let render = image.render;
33
+ if (!render) {
34
+ if (enabledElement.viewport.colormap) {
35
+ render = _rendering_renderPseudoColorImage__WEBPACK_IMPORTED_MODULE_3__/* .renderPseudoColorImage */ .l;
36
+ }
37
+ else if (image.color) {
38
+ render = _rendering_renderColorImage__WEBPACK_IMPORTED_MODULE_1__/* .renderColorImage */ .f;
39
+ }
40
+ else {
41
+ render = _rendering_renderGrayscaleImage__WEBPACK_IMPORTED_MODULE_2__/* .renderGrayscaleImage */ .j;
42
+ }
43
+ }
44
+ render(enabledElement, invalidated);
45
+ }
46
+ const renderTimeInMs = (0,_rendering_now__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)() - start;
47
+ image.stats.lastRenderTime = renderTimeInMs;
48
+ enabledElement.invalid = false;
49
+ enabledElement.needsRedraw = false;
50
+ }
51
+
52
+
53
+ /***/ }),
54
+
55
+ /***/ 7808:
56
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
57
+
58
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
59
+ /* harmony export */ A: () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)
60
+ /* harmony export */ });
61
+ /* harmony import */ var _transform__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(45354);
62
+
63
+ /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(enabledElement, scale) {
64
+ const transform = new _transform__WEBPACK_IMPORTED_MODULE_0__/* .Transform */ .d();
65
+ if (!enabledElement.viewport.displayedArea) {
66
+ return transform;
67
+ }
68
+ transform.translate(enabledElement.canvas.width / 2, enabledElement.canvas.height / 2);
69
+ const angle = enabledElement.viewport.rotation;
70
+ if (angle !== 0) {
71
+ transform.rotate((angle * Math.PI) / 180);
72
+ }
73
+ let widthScale = enabledElement.viewport.scale;
74
+ let heightScale = enabledElement.viewport.scale;
75
+ const width = enabledElement.viewport.displayedArea.brhc.x -
76
+ (enabledElement.viewport.displayedArea.tlhc.x - 1);
77
+ const height = enabledElement.viewport.displayedArea.brhc.y -
78
+ (enabledElement.viewport.displayedArea.tlhc.y - 1);
79
+ if (enabledElement.viewport.displayedArea.presentationSizeMode === 'NONE') {
80
+ if (enabledElement.image.rowPixelSpacing <
81
+ enabledElement.image.columnPixelSpacing) {
82
+ widthScale *=
83
+ enabledElement.image.columnPixelSpacing /
84
+ enabledElement.image.rowPixelSpacing;
85
+ }
86
+ else if (enabledElement.image.columnPixelSpacing <
87
+ enabledElement.image.rowPixelSpacing) {
88
+ heightScale *=
89
+ enabledElement.image.rowPixelSpacing /
90
+ enabledElement.image.columnPixelSpacing;
91
+ }
92
+ }
93
+ else {
94
+ widthScale = enabledElement.viewport.displayedArea.columnPixelSpacing;
95
+ heightScale = enabledElement.viewport.displayedArea.rowPixelSpacing;
96
+ if (enabledElement.viewport.displayedArea.presentationSizeMode ===
97
+ 'SCALE TO FIT') {
98
+ const verticalScale = enabledElement.canvas.height / (height * heightScale);
99
+ const horizontalScale = enabledElement.canvas.width / (width * widthScale);
100
+ widthScale = heightScale = Math.min(horizontalScale, verticalScale);
101
+ if (enabledElement.viewport.displayedArea.rowPixelSpacing <
102
+ enabledElement.viewport.displayedArea.columnPixelSpacing) {
103
+ widthScale *=
104
+ enabledElement.viewport.displayedArea.columnPixelSpacing /
105
+ enabledElement.viewport.displayedArea.rowPixelSpacing;
106
+ }
107
+ else if (enabledElement.viewport.displayedArea.columnPixelSpacing <
108
+ enabledElement.viewport.displayedArea.rowPixelSpacing) {
109
+ heightScale *=
110
+ enabledElement.viewport.displayedArea.rowPixelSpacing /
111
+ enabledElement.viewport.displayedArea.columnPixelSpacing;
112
+ }
113
+ }
114
+ }
115
+ transform.scale(widthScale, heightScale);
116
+ if (angle !== 0) {
117
+ transform.rotate((-angle * Math.PI) / 180);
118
+ }
119
+ transform.translate(enabledElement.viewport.translation.x, enabledElement.viewport.translation.y);
120
+ if (angle !== 0) {
121
+ transform.rotate((angle * Math.PI) / 180);
122
+ }
123
+ if (scale !== undefined) {
124
+ transform.scale(scale, scale);
125
+ }
126
+ if (enabledElement.viewport.hflip) {
127
+ transform.scale(-1, 1);
128
+ }
129
+ if (enabledElement.viewport.vflip) {
130
+ transform.scale(1, -1);
131
+ }
132
+ transform.translate(-width / 2, -height / 2);
133
+ return transform;
134
+ }
135
+
136
+
137
+ /***/ }),
138
+
139
+ /***/ 36931:
140
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
141
+
142
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
143
+ /* harmony export */ A: () => (/* export default binding */ __WEBPACK_DEFAULT_EXPORT__)
144
+ /* harmony export */ });
145
+ /* harmony import */ var _createViewport__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(12132);
146
+ /* harmony import */ var _getImageFitScale__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(57162);
147
+
148
+
149
+ /* harmony default export */ function __WEBPACK_DEFAULT_EXPORT__(canvas, image, modality, colormap) {
150
+ if (canvas === undefined) {
151
+ throw new Error('getDefaultViewport: parameter canvas must not be undefined');
152
+ }
153
+ if (image === undefined) {
154
+ return (0,_createViewport__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)();
155
+ }
156
+ const scale = (0,_getImageFitScale__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)(canvas, image, 0).scaleFactor;
157
+ let voi;
158
+ if (modality === 'PT' && image.isPreScaled) {
159
+ voi = {
160
+ windowWidth: 5,
161
+ windowCenter: 2.5,
162
+ };
163
+ }
164
+ else if (image.windowWidth !== undefined &&
165
+ image.windowCenter !== undefined) {
166
+ voi = {
167
+ windowWidth: Array.isArray(image.windowWidth)
168
+ ? image.windowWidth[0]
169
+ : image.windowWidth,
170
+ windowCenter: Array.isArray(image.windowCenter)
171
+ ? image.windowCenter[0]
172
+ : image.windowCenter,
173
+ };
174
+ }
175
+ return {
176
+ scale,
177
+ translation: {
178
+ x: 0,
179
+ y: 0,
180
+ },
181
+ voi,
182
+ invert: image.invert,
183
+ pixelReplication: false,
184
+ rotation: 0,
185
+ hflip: false,
186
+ vflip: false,
187
+ modalityLUT: image.modalityLUT,
188
+ modality,
189
+ voiLUT: image.voiLUT,
190
+ colormap: colormap !== undefined ? colormap : image.colormap,
191
+ displayedArea: {
192
+ tlhc: {
193
+ x: 1,
194
+ y: 1,
195
+ },
196
+ brhc: {
197
+ x: image.columns,
198
+ y: image.rows,
199
+ },
200
+ rowPixelSpacing: image.rowPixelSpacing === undefined ? 1 : image.rowPixelSpacing,
201
+ columnPixelSpacing: image.columnPixelSpacing === undefined ? 1 : image.columnPixelSpacing,
202
+ presentationSizeMode: 'NONE',
203
+ },
204
+ };
205
+ }
206
+
207
+
208
+ /***/ }),
209
+
210
+ /***/ 56750:
211
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
212
+
213
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
214
+ /* harmony export */ A: () => (/* binding */ FrameRange)
215
+ /* harmony export */ });
216
+ class FrameRange {
217
+ static { this.frameRangeExtractor = /(\/frames\/|[&?]frameNumber=)([^/&?]*)/i; }
218
+ static imageIdToFrames(imageId) {
219
+ const match = imageId.match(this.frameRangeExtractor);
220
+ if (!match || !match[2]) {
221
+ return null;
222
+ }
223
+ const range = match[2].split('-').map((it) => Number(it));
224
+ if (range.length === 1) {
225
+ return range[0];
226
+ }
227
+ return range;
228
+ }
229
+ static imageIdToFrameEnd(imageId) {
230
+ const range = this.imageIdToFrames(imageId);
231
+ return Array.isArray(range) ? range[1] : range;
232
+ }
233
+ static imageIdToFrameStart(imageId) {
234
+ const range = this.imageIdToFrames(imageId);
235
+ return Array.isArray(range) ? range[0] : range;
236
+ }
237
+ static framesToString(range) {
238
+ if (Array.isArray(range)) {
239
+ return `${range[0]}-${range[1]}`;
240
+ }
241
+ return String(range);
242
+ }
243
+ static framesToImageId(imageId, range) {
244
+ const match = imageId.match(this.frameRangeExtractor);
245
+ if (!match || !match[2]) {
246
+ return null;
247
+ }
248
+ const newRangeString = this.framesToString(range);
249
+ return imageId.replace(this.frameRangeExtractor, `${match[1]}${newRangeString}`);
250
+ }
251
+ }
252
+
253
+
254
+ /***/ }),
255
+
256
+ /***/ 13876:
257
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
258
+
259
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
260
+ /* harmony export */ A: () => (/* binding */ PointsManager)
261
+ /* harmony export */ });
262
+ class PointsManager {
263
+ constructor(configuration = {}) {
264
+ this._dimensions = 3;
265
+ this._length = 0;
266
+ this._byteSize = 4;
267
+ this.growSize = 128;
268
+ const { initialSize = 1024, dimensions = 3, growSize = 128, } = configuration;
269
+ const itemLength = initialSize * dimensions;
270
+ this.growSize = growSize;
271
+ this.array = new ArrayBuffer(itemLength * this._byteSize);
272
+ this.data = new Float32Array(this.array);
273
+ this._dimensions = dimensions;
274
+ }
275
+ forEach(func) {
276
+ for (let i = 0; i < this._length; i++) {
277
+ func(this.getPoint(i), i);
278
+ }
279
+ }
280
+ get length() {
281
+ return this._length;
282
+ }
283
+ get dimensions() {
284
+ return this._dimensions;
285
+ }
286
+ get dimensionLength() {
287
+ return this._length * this._dimensions;
288
+ }
289
+ getPoint(index) {
290
+ if (index < 0) {
291
+ index += this._length;
292
+ }
293
+ if (index < 0 || index >= this._length) {
294
+ return;
295
+ }
296
+ const offset = this._dimensions * index;
297
+ return this.data.subarray(offset, offset + this._dimensions);
298
+ }
299
+ getPointArray(index) {
300
+ const array = [];
301
+ if (index < 0) {
302
+ index += this._length;
303
+ }
304
+ if (index < 0 || index >= this._length) {
305
+ return;
306
+ }
307
+ const offset = this._dimensions * index;
308
+ for (let i = 0; i < this._dimensions; i++) {
309
+ array.push(this.data[i + offset]);
310
+ }
311
+ return array;
312
+ }
313
+ grow(additionalSize = 1, growSize = this.growSize) {
314
+ if (this.dimensionLength + additionalSize * this._dimensions <=
315
+ this.data.length) {
316
+ return;
317
+ }
318
+ const newSize = this.data.length + growSize;
319
+ const newArray = new ArrayBuffer(newSize * this._dimensions * this._byteSize);
320
+ const newData = new Float32Array(newArray);
321
+ newData.set(this.data);
322
+ this.data = newData;
323
+ this.array = newArray;
324
+ }
325
+ reverse() {
326
+ const midLength = Math.floor(this._length / 2);
327
+ for (let i = 0; i < midLength; i++) {
328
+ const indexStart = i * this._dimensions;
329
+ const indexEnd = (this._length - 1 - i) * this._dimensions;
330
+ for (let dimension = 0; dimension < this._dimensions; dimension++) {
331
+ const valueStart = this.data[indexStart + dimension];
332
+ this.data[indexStart + dimension] = this.data[indexEnd + dimension];
333
+ this.data[indexEnd + dimension] = valueStart;
334
+ }
335
+ }
336
+ }
337
+ getTypedArray() {
338
+ return this.data;
339
+ }
340
+ push(point) {
341
+ this.grow(1);
342
+ const offset = this.length * this._dimensions;
343
+ for (let i = 0; i < this._dimensions; i++) {
344
+ this.data[i + offset] = point[i];
345
+ }
346
+ this._length++;
347
+ }
348
+ map(f) {
349
+ const mapData = [];
350
+ for (let i = 0; i < this._length; i++) {
351
+ mapData.push(f(this.getPoint(i), i));
352
+ }
353
+ return mapData;
354
+ }
355
+ get points() {
356
+ return this.map((p) => p);
357
+ }
358
+ toXYZ() {
359
+ const xyz = { x: [], y: [] };
360
+ if (this._dimensions >= 3) {
361
+ xyz.z = [];
362
+ }
363
+ const { x, y, z } = xyz;
364
+ this.forEach((p) => {
365
+ x.push(p[0]);
366
+ y.push(p[1]);
367
+ if (z) {
368
+ z.push(p[2]);
369
+ }
370
+ });
371
+ return xyz;
372
+ }
373
+ static fromXYZ({ x, y, z }) {
374
+ const array = PointsManager.create3(x.length);
375
+ let offset = 0;
376
+ for (let i = 0; i < x.length; i++) {
377
+ array.data[offset++] = x[i];
378
+ array.data[offset++] = y[i];
379
+ array.data[offset++] = z ? z[i] : 0;
380
+ }
381
+ array._length = x.length;
382
+ return array;
383
+ }
384
+ subselect(count = 10, offset = 0) {
385
+ const selected = new PointsManager({
386
+ initialSize: count,
387
+ dimensions: this._dimensions,
388
+ });
389
+ for (let i = 0; i < count; i++) {
390
+ const index = (offset + Math.floor((this.length * i) / count)) % this.length;
391
+ selected.push(this.getPoint(index));
392
+ }
393
+ return selected;
394
+ }
395
+ static create3(initialSize = 128, points) {
396
+ initialSize = Math.max(initialSize, points?.length || 0);
397
+ const newPoints = new PointsManager({ initialSize, dimensions: 3 });
398
+ if (points) {
399
+ points.forEach((point) => newPoints.push(point));
400
+ }
401
+ return newPoints;
402
+ }
403
+ static create2(initialSize = 128) {
404
+ return new PointsManager({ initialSize, dimensions: 2 });
405
+ }
406
+ }
407
+
408
+
409
+ /***/ }),
410
+
411
+ /***/ 22191:
412
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
413
+
414
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
415
+ /* harmony export */ A: () => (/* binding */ ProgressiveIterator)
416
+ /* harmony export */ });
417
+ /* unused harmony export PromiseIterator */
418
+ class PromiseIterator extends (/* unused pure expression or super */ null && (Promise)) {
419
+ }
420
+ class ProgressiveIterator {
421
+ constructor(name) {
422
+ this.name = name || 'unknown';
423
+ }
424
+ static as(promise) {
425
+ if (promise.iterator) {
426
+ return promise.iterator;
427
+ }
428
+ const iterator = new ProgressiveIterator('as iterator');
429
+ promise.then((v) => {
430
+ try {
431
+ iterator.add(v, true);
432
+ }
433
+ catch (e) {
434
+ iterator.reject(e);
435
+ }
436
+ }, (reason) => {
437
+ iterator.reject(reason);
438
+ });
439
+ return iterator;
440
+ }
441
+ add(x, done = false) {
442
+ this.nextValue = x;
443
+ this.done ||= done;
444
+ if (this.waiting) {
445
+ this.waiting.resolve(x);
446
+ this.waiting = undefined;
447
+ }
448
+ }
449
+ resolve() {
450
+ this.done = true;
451
+ if (this.waiting) {
452
+ this.waiting.resolve(this.nextValue);
453
+ this.waiting = undefined;
454
+ }
455
+ }
456
+ reject(reason) {
457
+ this.rejectReason = reason;
458
+ this.waiting?.reject(reason);
459
+ }
460
+ getRecent() {
461
+ if (this.rejectReason) {
462
+ throw this.rejectReason;
463
+ }
464
+ return this.nextValue;
465
+ }
466
+ async *[Symbol.asyncIterator]() {
467
+ while (!this.done) {
468
+ if (this.rejectReason) {
469
+ throw this.rejectReason;
470
+ }
471
+ if (this.nextValue !== undefined) {
472
+ yield this.nextValue;
473
+ if (this.done) {
474
+ break;
475
+ }
476
+ }
477
+ if (!this.waiting) {
478
+ this.waiting = {};
479
+ this.waiting.promise = new Promise((resolve, reject) => {
480
+ this.waiting.resolve = resolve;
481
+ this.waiting.reject = reject;
482
+ });
483
+ }
484
+ await this.waiting.promise;
485
+ }
486
+ yield this.nextValue;
487
+ }
488
+ async forEach(callback, errorCallback) {
489
+ let index = 0;
490
+ try {
491
+ for await (const value of this) {
492
+ const { done } = this;
493
+ try {
494
+ await callback(value, done, index);
495
+ index++;
496
+ }
497
+ catch (e) {
498
+ if (!done) {
499
+ console.warn('Caught exception in intermediate value', e);
500
+ continue;
501
+ }
502
+ if (errorCallback) {
503
+ errorCallback(e, done);
504
+ }
505
+ else {
506
+ throw e;
507
+ }
508
+ }
509
+ }
510
+ }
511
+ catch (e) {
512
+ if (errorCallback) {
513
+ errorCallback(e, true);
514
+ }
515
+ else {
516
+ throw e;
517
+ }
518
+ }
519
+ }
520
+ generate(processFunction, errorCallback) {
521
+ return processFunction(this, this.reject.bind(this)).then(() => {
522
+ if (!this.done) {
523
+ this.resolve();
524
+ }
525
+ }, (reason) => {
526
+ this.reject(reason);
527
+ if (errorCallback) {
528
+ errorCallback(reason);
529
+ }
530
+ else {
531
+ console.warn("Couldn't process because", reason);
532
+ }
533
+ });
534
+ }
535
+ async nextPromise() {
536
+ for await (const i of this) {
537
+ if (i) {
538
+ return i;
539
+ }
540
+ }
541
+ return this.nextValue;
542
+ }
543
+ async donePromise() {
544
+ for await (const i of this) {
545
+ }
546
+ return this.nextValue;
547
+ }
548
+ getNextPromise() {
549
+ const promise = this.nextPromise();
550
+ promise.iterator = this;
551
+ return promise;
552
+ }
553
+ getDonePromise() {
554
+ const promise = this.donePromise();
555
+ promise.iterator = this;
556
+ return promise;
557
+ }
558
+ }
559
+
560
+
561
+ /***/ }),
562
+
563
+ /***/ 67645:
564
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
565
+
566
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
567
+ /* harmony export */ A: () => (/* binding */ RLEVoxelMap)
568
+ /* harmony export */ });
569
+ const ADJACENT_ALL = [
570
+ [0, -1, 0],
571
+ [0, 1, 0],
572
+ [0, 0, -1],
573
+ [0, 0, 1],
574
+ ];
575
+ const ADJACENT_SINGLE_PLANE = [
576
+ [0, -1, 0],
577
+ [0, 1, 0],
578
+ ];
579
+ const ADJACENT_IN = [
580
+ [0, -1, 0],
581
+ [0, 1, 0],
582
+ [0, 0, -1],
583
+ ];
584
+ const ADJACENT_OUT = [
585
+ [0, -1, 0],
586
+ [0, 1, 0],
587
+ [0, 0, 1],
588
+ ];
589
+ class RLEVoxelMap {
590
+ static copyMap(destination, source) {
591
+ for (const [index, row] of source.rows) {
592
+ destination.rows.set(index, structuredClone(row));
593
+ }
594
+ }
595
+ constructor(width, height, depth = 1) {
596
+ this.rows = new Map();
597
+ this.height = 1;
598
+ this.width = 1;
599
+ this.depth = 1;
600
+ this.jMultiple = 1;
601
+ this.kMultiple = 1;
602
+ this.numComps = 1;
603
+ this.pixelDataConstructor = Uint8Array;
604
+ this.updateScalarData = function (scalarData) {
605
+ scalarData.fill(0);
606
+ const callback = (index, rle, row) => {
607
+ const { start, end, value } = rle;
608
+ for (let i = start; i < end; i++) {
609
+ scalarData[index + i] = value;
610
+ }
611
+ };
612
+ this.forEach(callback);
613
+ };
614
+ this.get = (index) => {
615
+ const i = index % this.jMultiple;
616
+ const j = (index - i) / this.jMultiple;
617
+ const rle = this.getRLE(i, j);
618
+ return rle?.value ?? this.defaultValue;
619
+ };
620
+ this.getRun = (j, k) => {
621
+ const runIndex = j + k * this.height;
622
+ return this.rows.get(runIndex);
623
+ };
624
+ this.set = (index, value) => {
625
+ if (value === undefined) {
626
+ return;
627
+ }
628
+ const i = index % this.width;
629
+ const j = (index - i) / this.width;
630
+ const row = this.rows.get(j);
631
+ if (!row) {
632
+ this.rows.set(j, [{ start: i, end: i + 1, value }]);
633
+ return;
634
+ }
635
+ const rleIndex = this.findIndex(row, i);
636
+ const rle1 = row[rleIndex];
637
+ const rle0 = row[rleIndex - 1];
638
+ if (!rle1) {
639
+ if (!rle0 || rle0.value !== value || rle0.end !== i) {
640
+ row[rleIndex] = { start: i, end: i + 1, value };
641
+ return;
642
+ }
643
+ rle0.end++;
644
+ return;
645
+ }
646
+ const { start, end, value: oldValue } = rle1;
647
+ if (value === oldValue && i >= start) {
648
+ return;
649
+ }
650
+ const rleInsert = { start: i, end: i + 1, value };
651
+ const isAfter = i > start;
652
+ const insertIndex = isAfter ? rleIndex + 1 : rleIndex;
653
+ const rlePrev = isAfter ? rle1 : rle0;
654
+ let rleNext = isAfter ? row[rleIndex + 1] : rle1;
655
+ if (rlePrev?.value === value && rlePrev?.end === i) {
656
+ rlePrev.end++;
657
+ if (rleNext?.value === value && rleNext.start === i + 1) {
658
+ rlePrev.end = rleNext.end;
659
+ row.splice(rleIndex, 1);
660
+ }
661
+ else if (rleNext?.start === i) {
662
+ rleNext.start++;
663
+ if (rleNext.start === rleNext.end) {
664
+ row.splice(rleIndex, 1);
665
+ rleNext = row[rleIndex];
666
+ if (rleNext?.start === i + 1 && rleNext.value === value) {
667
+ rlePrev.end = rleNext.end;
668
+ row.splice(rleIndex, 1);
669
+ }
670
+ }
671
+ }
672
+ return;
673
+ }
674
+ if (rleNext?.value === value && rleNext.start === i + 1) {
675
+ rleNext.start--;
676
+ if (rlePrev?.end > i) {
677
+ rlePrev.end = i;
678
+ if (rlePrev.end === rlePrev.start) {
679
+ row.splice(rleIndex, 1);
680
+ }
681
+ }
682
+ return;
683
+ }
684
+ if (rleNext?.start === i && rleNext.end === i + 1) {
685
+ rleNext.value = value;
686
+ const nextnext = row[rleIndex + 1];
687
+ if (nextnext?.start == i + 1 && nextnext.value === value) {
688
+ row.splice(rleIndex + 1, 1);
689
+ rleNext.end = nextnext.end;
690
+ }
691
+ return;
692
+ }
693
+ if (i === rleNext?.start) {
694
+ rleNext.start++;
695
+ }
696
+ if (isAfter && end > i + 1) {
697
+ row.splice(insertIndex, 0, rleInsert, {
698
+ start: i + 1,
699
+ end: rlePrev.end,
700
+ value: rlePrev.value,
701
+ });
702
+ }
703
+ else {
704
+ row.splice(insertIndex, 0, rleInsert);
705
+ }
706
+ if (rlePrev?.end > i) {
707
+ rlePrev.end = i;
708
+ }
709
+ };
710
+ this.width = width;
711
+ this.height = height;
712
+ this.depth = depth;
713
+ this.jMultiple = width;
714
+ this.kMultiple = this.jMultiple * height;
715
+ }
716
+ static { this.getScalarData = function (ArrayType = Uint8ClampedArray) {
717
+ const scalarData = new ArrayType(this.frameSize);
718
+ this.map.updateScalarData(scalarData);
719
+ return scalarData;
720
+ }; }
721
+ toIJK(index) {
722
+ const i = index % this.jMultiple;
723
+ const j = ((index - i) / this.jMultiple) % this.height;
724
+ const k = Math.floor(index / this.kMultiple);
725
+ return [i, j, k];
726
+ }
727
+ toIndex([i, j, k]) {
728
+ return i + k * this.kMultiple + j * this.jMultiple;
729
+ }
730
+ getRLE(i, j, k = 0) {
731
+ const row = this.rows.get(j + k * this.height);
732
+ if (!row) {
733
+ return;
734
+ }
735
+ const index = this.findIndex(row, i);
736
+ const rle = row[index];
737
+ return i >= rle?.start ? rle : undefined;
738
+ }
739
+ has(index) {
740
+ const i = index % this.jMultiple;
741
+ const j = (index - i) / this.jMultiple;
742
+ const rle = this.getRLE(i, j);
743
+ return rle?.value !== undefined;
744
+ }
745
+ delete(index) {
746
+ const i = index % this.width;
747
+ const j = (index - i) / this.width;
748
+ const row = this.rows.get(j);
749
+ if (!row) {
750
+ return;
751
+ }
752
+ const rleIndex = this.findIndex(row, i);
753
+ const rle = row[rleIndex];
754
+ if (!rle || rle.start > i) {
755
+ return;
756
+ }
757
+ if (rle.end === i + 1) {
758
+ rle.end--;
759
+ if (rle.start >= rle.end) {
760
+ row.splice(rleIndex, 1);
761
+ if (!row.length) {
762
+ this.rows.delete(j);
763
+ }
764
+ }
765
+ return;
766
+ }
767
+ if (rle.start === i) {
768
+ rle.start++;
769
+ return;
770
+ }
771
+ const newRle = {
772
+ value: rle.value,
773
+ start: i + 1,
774
+ end: rle.end,
775
+ };
776
+ rle.end = i;
777
+ row.splice(rleIndex + 1, 0, newRle);
778
+ }
779
+ findIndex(row, i) {
780
+ for (let index = 0; index < row.length; index++) {
781
+ const { end: iEnd } = row[index];
782
+ if (i < iEnd) {
783
+ return index;
784
+ }
785
+ }
786
+ return row.length;
787
+ }
788
+ forEach(callback, options) {
789
+ const rowModified = options?.rowModified;
790
+ for (const [baseIndex, row] of this.rows) {
791
+ const rowToUse = rowModified ? [...row] : row;
792
+ for (const rle of rowToUse) {
793
+ callback(baseIndex * this.width, rle, row);
794
+ }
795
+ }
796
+ }
797
+ forEachRow(callback) {
798
+ for (const [baseIndex, row] of this.rows) {
799
+ callback(baseIndex * this.width, row);
800
+ }
801
+ }
802
+ clear() {
803
+ this.rows.clear();
804
+ }
805
+ keys() {
806
+ return [...this.rows.keys()];
807
+ }
808
+ getPixelData(k = 0, pixelData) {
809
+ if (!pixelData) {
810
+ pixelData = new this.pixelDataConstructor(this.width * this.height * this.numComps);
811
+ }
812
+ else {
813
+ pixelData.fill(0);
814
+ }
815
+ const { width, height, numComps } = this;
816
+ for (let j = 0; j < height; j++) {
817
+ const row = this.getRun(j, k);
818
+ if (!row) {
819
+ continue;
820
+ }
821
+ if (numComps === 1) {
822
+ for (const rle of row) {
823
+ const rowOffset = j * width;
824
+ const { start, end, value } = rle;
825
+ for (let i = start; i < end; i++) {
826
+ pixelData[rowOffset + i] = value;
827
+ }
828
+ }
829
+ }
830
+ else {
831
+ for (const rle of row) {
832
+ const rowOffset = j * width * numComps;
833
+ const { start, end, value } = rle;
834
+ for (let i = start; i < end; i += numComps) {
835
+ for (let comp = 0; comp < numComps; comp++) {
836
+ pixelData[rowOffset + i + comp] = value[comp];
837
+ }
838
+ }
839
+ }
840
+ }
841
+ }
842
+ return pixelData;
843
+ }
844
+ floodFill(i, j, k, value, options) {
845
+ const rle = this.getRLE(i, j, k);
846
+ if (!rle) {
847
+ throw new Error(`Initial point ${i},${j},${k} isn't in the RLE`);
848
+ }
849
+ const stack = [[rle, j, k]];
850
+ const replaceValue = rle.value;
851
+ if (replaceValue === value) {
852
+ throw new Error(`source (${replaceValue}) and destination (${value}) are identical`);
853
+ }
854
+ return this.flood(stack, replaceValue, value, options);
855
+ }
856
+ flood(stack, sourceValue, value, options) {
857
+ let sum = 0;
858
+ const { planar = true, diagonals = true, singlePlane = false, } = options || {};
859
+ const childOptions = { planar, diagonals, singlePlane };
860
+ while (stack.length) {
861
+ const top = stack.pop();
862
+ const [current] = top;
863
+ if (current.value !== sourceValue) {
864
+ continue;
865
+ }
866
+ current.value = value;
867
+ sum += current.end - current.start;
868
+ const adjacents = this.findAdjacents(top, childOptions).filter((adjacent) => adjacent && adjacent[0].value === sourceValue);
869
+ stack.push(...adjacents);
870
+ }
871
+ return sum;
872
+ }
873
+ fillFrom(getter, boundsIJK) {
874
+ for (let k = boundsIJK[2][0]; k <= boundsIJK[2][1]; k++) {
875
+ for (let j = boundsIJK[1][0]; j <= boundsIJK[1][1]; j++) {
876
+ let rle;
877
+ let row;
878
+ for (let i = boundsIJK[0][0]; i <= boundsIJK[0][1]; i++) {
879
+ const value = getter(i, j, k);
880
+ if (value === undefined) {
881
+ rle = undefined;
882
+ continue;
883
+ }
884
+ if (!row) {
885
+ row = [];
886
+ this.rows.set(j + k * this.height, row);
887
+ }
888
+ if (rle && rle.value !== value) {
889
+ rle = undefined;
890
+ }
891
+ if (!rle) {
892
+ rle = { start: i, end: i, value };
893
+ row.push(rle);
894
+ }
895
+ rle.end++;
896
+ }
897
+ }
898
+ }
899
+ }
900
+ findAdjacents(item, { diagonals = true, planar = true, singlePlane = false }) {
901
+ const [rle, j, k, adjacentsDelta] = item;
902
+ const { start, end } = rle;
903
+ const leftRle = start > 0 && this.getRLE(start - 1, j, k);
904
+ const rightRle = end < this.width && this.getRLE(end, j, k);
905
+ const range = diagonals
906
+ ? [start > 0 ? start - 1 : start, end < this.width ? end + 1 : end]
907
+ : [start, end];
908
+ const adjacents = [];
909
+ if (leftRle) {
910
+ adjacents.push([leftRle, j, k]);
911
+ }
912
+ if (rightRle) {
913
+ adjacents.push([rightRle, j, k]);
914
+ }
915
+ for (const delta of adjacentsDelta ||
916
+ (singlePlane ? ADJACENT_SINGLE_PLANE : ADJACENT_ALL)) {
917
+ const [, delta1, delta2] = delta;
918
+ const testJ = delta1 + j;
919
+ const testK = delta2 + k;
920
+ if (testJ < 0 || testJ >= this.height) {
921
+ continue;
922
+ }
923
+ if (testK < 0 || testK >= this.depth) {
924
+ continue;
925
+ }
926
+ const row = this.getRun(testJ, testK);
927
+ if (!row) {
928
+ continue;
929
+ }
930
+ for (const testRle of row) {
931
+ const newAdjacentDelta = adjacentsDelta ||
932
+ (singlePlane && ADJACENT_SINGLE_PLANE) ||
933
+ (planar && delta2 > 0 && ADJACENT_OUT) ||
934
+ (planar && delta2 < 0 && ADJACENT_IN) ||
935
+ ADJACENT_ALL;
936
+ if (!(testRle.end <= range[0] || testRle.start >= range[1])) {
937
+ adjacents.push([testRle, testJ, testK, newAdjacentDelta]);
938
+ }
939
+ }
940
+ }
941
+ return adjacents;
942
+ }
943
+ }
944
+
945
+
946
+ /***/ }),
947
+
948
+ /***/ 98039:
949
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
950
+
951
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
952
+ /* harmony export */ N: () => (/* binding */ actorIsA),
953
+ /* harmony export */ e: () => (/* binding */ isImageActor)
954
+ /* harmony export */ });
955
+ function isImageActor(actorEntry) {
956
+ return (actorIsA(actorEntry, 'vtkVolume') || actorIsA(actorEntry, 'vtkImageSlice'));
957
+ }
958
+ function actorIsA(actorEntry, actorType) {
959
+ const actorToCheck = 'isA' in actorEntry ? actorEntry : actorEntry.actor;
960
+ if (!actorToCheck) {
961
+ return false;
962
+ }
963
+ return !!actorToCheck.isA(actorType);
964
+ }
965
+
966
+
967
+ /***/ }),
968
+
969
+ /***/ 96833:
970
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
971
+
972
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
973
+ /* harmony export */ A: () => (/* binding */ applyPreset)
974
+ /* harmony export */ });
975
+ /* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(33739);
976
+ /* harmony import */ var _kitware_vtk_js_Common_DataModel_PiecewiseFunction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(99341);
977
+
978
+
979
+ function applyPreset(actor, preset) {
980
+ const colorTransferArray = preset.colorTransfer
981
+ .split(' ')
982
+ .splice(1)
983
+ .map(parseFloat);
984
+ const { shiftRange } = getShiftRange(colorTransferArray);
985
+ const min = shiftRange[0];
986
+ const width = shiftRange[1] - shiftRange[0];
987
+ const cfun = _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__/* ["default"].newInstance */ .Ay.newInstance();
988
+ const normColorTransferValuePoints = [];
989
+ for (let i = 0; i < colorTransferArray.length; i += 4) {
990
+ let value = colorTransferArray[i];
991
+ const r = colorTransferArray[i + 1];
992
+ const g = colorTransferArray[i + 2];
993
+ const b = colorTransferArray[i + 3];
994
+ value = (value - min) / width;
995
+ normColorTransferValuePoints.push([value, r, g, b]);
996
+ }
997
+ applyPointsToRGBFunction(normColorTransferValuePoints, shiftRange, cfun);
998
+ actor.getProperty().setRGBTransferFunction(0, cfun);
999
+ const scalarOpacityArray = preset.scalarOpacity
1000
+ .split(' ')
1001
+ .splice(1)
1002
+ .map(parseFloat);
1003
+ const ofun = _kitware_vtk_js_Common_DataModel_PiecewiseFunction__WEBPACK_IMPORTED_MODULE_1__/* ["default"].newInstance */ .Ay.newInstance();
1004
+ const normPoints = [];
1005
+ for (let i = 0; i < scalarOpacityArray.length; i += 2) {
1006
+ let value = scalarOpacityArray[i];
1007
+ const opacity = scalarOpacityArray[i + 1];
1008
+ value = (value - min) / width;
1009
+ normPoints.push([value, opacity]);
1010
+ }
1011
+ applyPointsToPiecewiseFunction(normPoints, shiftRange, ofun);
1012
+ const property = actor.getProperty();
1013
+ property.setScalarOpacity(0, ofun);
1014
+ const [gradientMinValue, gradientMinOpacity, gradientMaxValue, gradientMaxOpacity,] = preset.gradientOpacity.split(' ').splice(1).map(parseFloat);
1015
+ property.setUseGradientOpacity(0, true);
1016
+ property.setGradientOpacityMinimumValue(0, gradientMinValue);
1017
+ property.setGradientOpacityMinimumOpacity(0, gradientMinOpacity);
1018
+ property.setGradientOpacityMaximumValue(0, gradientMaxValue);
1019
+ property.setGradientOpacityMaximumOpacity(0, gradientMaxOpacity);
1020
+ if (preset.interpolation === '1') {
1021
+ property.setInterpolationTypeToFastLinear();
1022
+ }
1023
+ property.setShade(preset.shade === '1');
1024
+ const ambient = parseFloat(preset.ambient);
1025
+ const diffuse = parseFloat(preset.diffuse);
1026
+ const specular = parseFloat(preset.specular);
1027
+ const specularPower = parseFloat(preset.specularPower);
1028
+ property.setAmbient(ambient);
1029
+ property.setDiffuse(diffuse);
1030
+ property.setSpecular(specular);
1031
+ property.setSpecularPower(specularPower);
1032
+ }
1033
+ function getShiftRange(colorTransferArray) {
1034
+ let min = Infinity;
1035
+ let max = -Infinity;
1036
+ for (let i = 0; i < colorTransferArray.length; i += 4) {
1037
+ min = Math.min(min, colorTransferArray[i]);
1038
+ max = Math.max(max, colorTransferArray[i]);
1039
+ }
1040
+ const center = (max - min) / 2;
1041
+ return {
1042
+ shiftRange: [-center, center],
1043
+ min,
1044
+ max,
1045
+ };
1046
+ }
1047
+ function applyPointsToRGBFunction(points, range, cfun) {
1048
+ const width = range[1] - range[0];
1049
+ const rescaled = points.map(([x, r, g, b]) => [
1050
+ x * width + range[0],
1051
+ r,
1052
+ g,
1053
+ b,
1054
+ ]);
1055
+ cfun.removeAllPoints();
1056
+ rescaled.forEach(([x, r, g, b]) => cfun.addRGBPoint(x, r, g, b));
1057
+ return rescaled;
1058
+ }
1059
+ function applyPointsToPiecewiseFunction(points, range, pwf) {
1060
+ const width = range[1] - range[0];
1061
+ const rescaled = points.map(([x, y]) => [x * width + range[0], y]);
1062
+ pwf.removeAllPoints();
1063
+ rescaled.forEach(([x, y]) => pwf.addPoint(x, y));
1064
+ return rescaled;
1065
+ }
1066
+
1067
+
1068
+ /***/ }),
1069
+
1070
+ /***/ 91979:
1071
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1072
+
1073
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1074
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
1075
+ /* harmony export */ });
1076
+ /* harmony import */ var _RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(39536);
1077
+ /* harmony import */ var _getViewportsWithVolumeId__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(24724);
1078
+
1079
+
1080
+ const autoLoad = (volumeId) => {
1081
+ const renderingEngineAndViewportIds = getRenderingEngineAndViewportsContainingVolume(volumeId);
1082
+ if (!renderingEngineAndViewportIds?.length) {
1083
+ return;
1084
+ }
1085
+ renderingEngineAndViewportIds.forEach(({ renderingEngine, viewportIds }) => {
1086
+ if (!renderingEngine.hasBeenDestroyed) {
1087
+ renderingEngine.renderViewports(viewportIds);
1088
+ }
1089
+ });
1090
+ };
1091
+ function getRenderingEngineAndViewportsContainingVolume(volumeId) {
1092
+ const renderingEnginesArray = (0,_RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_0__/* .getRenderingEngines */ .qO)();
1093
+ const renderingEngineAndViewportIds = [];
1094
+ renderingEnginesArray.forEach((renderingEngine) => {
1095
+ const viewports = (0,_getViewportsWithVolumeId__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)(volumeId);
1096
+ if (viewports.length) {
1097
+ renderingEngineAndViewportIds.push({
1098
+ renderingEngine,
1099
+ viewportIds: viewports.map((viewport) => viewport.id),
1100
+ });
1101
+ }
1102
+ });
1103
+ return renderingEngineAndViewportIds;
1104
+ }
1105
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (autoLoad);
1106
+
1107
+
1108
+ /***/ }),
1109
+
1110
+ /***/ 42384:
1111
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1112
+
1113
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1114
+ /* harmony export */ A: () => (/* binding */ calculateSpacingBetweenImageIds)
1115
+ /* harmony export */ });
1116
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
1117
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(74876);
1118
+ /* harmony import */ var _init__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(59693);
1119
+
1120
+
1121
+
1122
+ function calculateSpacingBetweenImageIds(imageIds) {
1123
+ const { imagePositionPatient: referenceImagePositionPatient, imageOrientationPatient, } = _metaData__WEBPACK_IMPORTED_MODULE_1__.get('imagePlaneModule', imageIds[0]);
1124
+ const rowCosineVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.fromValues */ .eR.fromValues(imageOrientationPatient[0], imageOrientationPatient[1], imageOrientationPatient[2]);
1125
+ const colCosineVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.fromValues */ .eR.fromValues(imageOrientationPatient[3], imageOrientationPatient[4], imageOrientationPatient[5]);
1126
+ const scanAxisNormal = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create();
1127
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.cross */ .eR.cross(scanAxisNormal, rowCosineVec, colCosineVec);
1128
+ const refIppVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.fromValues */ .eR.fromValues(referenceImagePositionPatient[0], referenceImagePositionPatient[1], referenceImagePositionPatient[2]);
1129
+ const usingWadoUri = imageIds[0].split(':')[0] === 'wadouri';
1130
+ let spacing;
1131
+ function getDistance(imageId) {
1132
+ const { imagePositionPatient } = _metaData__WEBPACK_IMPORTED_MODULE_1__.get('imagePlaneModule', imageId);
1133
+ const positionVector = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create();
1134
+ const ippVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.fromValues */ .eR.fromValues(imagePositionPatient[0], imagePositionPatient[1], imagePositionPatient[2]);
1135
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.sub */ .eR.sub(positionVector, refIppVec, ippVec);
1136
+ return gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(positionVector, scanAxisNormal);
1137
+ }
1138
+ if (!usingWadoUri) {
1139
+ const distanceImagePairs = imageIds.map((imageId) => {
1140
+ const distance = getDistance(imageId);
1141
+ return {
1142
+ distance,
1143
+ imageId,
1144
+ };
1145
+ });
1146
+ distanceImagePairs.sort((a, b) => b.distance - a.distance);
1147
+ const numImages = distanceImagePairs.length;
1148
+ spacing =
1149
+ Math.abs(distanceImagePairs[numImages - 1].distance -
1150
+ distanceImagePairs[0].distance) /
1151
+ (numImages - 1);
1152
+ }
1153
+ else {
1154
+ const prefetchedImageIds = [
1155
+ imageIds[0],
1156
+ imageIds[Math.floor(imageIds.length / 2)],
1157
+ ];
1158
+ const firstImageDistance = getDistance(prefetchedImageIds[0]);
1159
+ const middleImageDistance = getDistance(prefetchedImageIds[1]);
1160
+ const metadataForMiddleImage = _metaData__WEBPACK_IMPORTED_MODULE_1__.get('imagePlaneModule', prefetchedImageIds[1]);
1161
+ if (!metadataForMiddleImage) {
1162
+ throw new Error('Incomplete metadata required for volume construction.');
1163
+ }
1164
+ const positionVector = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create();
1165
+ const middleIppVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.fromValues */ .eR.fromValues(metadataForMiddleImage.imagePositionPatient[0], metadataForMiddleImage.imagePositionPatient[1], metadataForMiddleImage.imagePositionPatient[2]);
1166
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.sub */ .eR.sub(positionVector, refIppVec, middleIppVec);
1167
+ const distanceBetweenFirstAndMiddleImages = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(positionVector, scanAxisNormal);
1168
+ spacing =
1169
+ Math.abs(distanceBetweenFirstAndMiddleImages) /
1170
+ Math.floor(imageIds.length / 2);
1171
+ }
1172
+ const { sliceThickness, spacingBetweenSlices } = _metaData__WEBPACK_IMPORTED_MODULE_1__.get('imagePlaneModule', imageIds[0]);
1173
+ const { strictZSpacingForVolumeViewport } = (0,_init__WEBPACK_IMPORTED_MODULE_2__/* .getConfiguration */ .D0)().rendering;
1174
+ if (spacing === 0 && !strictZSpacingForVolumeViewport) {
1175
+ if (spacingBetweenSlices) {
1176
+ console.debug('Could not calculate spacing. Using spacingBetweenSlices');
1177
+ spacing = spacingBetweenSlices;
1178
+ }
1179
+ else if (sliceThickness) {
1180
+ console.debug('Could not calculate spacing and no spacingBetweenSlices. Using sliceThickness');
1181
+ spacing = sliceThickness;
1182
+ }
1183
+ else {
1184
+ console.debug('Could not calculate spacing. The VolumeViewport visualization is compromised. Setting spacing to 1 to render');
1185
+ spacing = 1;
1186
+ }
1187
+ }
1188
+ return spacing;
1189
+ }
1190
+
1191
+
1192
+ /***/ }),
1193
+
1194
+ /***/ 74657:
1195
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1196
+
1197
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1198
+ /* harmony export */ A: () => (/* binding */ createLinearRGBTransferFunction)
1199
+ /* harmony export */ });
1200
+ /* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(33739);
1201
+
1202
+ function createLinearRGBTransferFunction(voiRange) {
1203
+ const cfun = _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__/* ["default"].newInstance */ .Ay.newInstance();
1204
+ let lower = 0;
1205
+ let upper = 1024;
1206
+ if (voiRange.lower !== undefined && voiRange.upper !== undefined) {
1207
+ lower = voiRange.lower;
1208
+ upper = voiRange.upper;
1209
+ }
1210
+ cfun.addRGBPoint(lower, 0.0, 0.0, 0.0);
1211
+ cfun.addRGBPoint(upper, 1.0, 1.0, 1.0);
1212
+ return cfun;
1213
+ }
1214
+
1215
+
1216
+ /***/ }),
1217
+
1218
+ /***/ 40256:
1219
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1220
+
1221
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1222
+ /* harmony export */ A: () => (/* binding */ createSigmoidRGBTransferFunction)
1223
+ /* harmony export */ });
1224
+ /* harmony import */ var _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(33739);
1225
+ /* harmony import */ var _kitware_vtk_js_Common_Core_DataArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(42008);
1226
+ /* harmony import */ var _windowLevel__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(68136);
1227
+ /* harmony import */ var _logit__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(58977);
1228
+
1229
+
1230
+
1231
+
1232
+ function createSigmoidRGBTransferFunction(voiRange, approximationNodes = 1024) {
1233
+ const { windowWidth, windowCenter } = _windowLevel__WEBPACK_IMPORTED_MODULE_2__.toWindowLevel(voiRange.lower, voiRange.upper);
1234
+ const range = Array.from({ length: approximationNodes }, (_, i) => (i + 1) / (approximationNodes + 2));
1235
+ const table = range.flatMap((y) => {
1236
+ const x = (0,_logit__WEBPACK_IMPORTED_MODULE_3__/* .logit */ .i)(y, windowCenter, windowWidth);
1237
+ return [x, y, y, y, 0.5, 0.0];
1238
+ });
1239
+ const cfun = _kitware_vtk_js_Rendering_Core_ColorTransferFunction__WEBPACK_IMPORTED_MODULE_0__/* ["default"].newInstance */ .Ay.newInstance();
1240
+ cfun.buildFunctionFromArray(_kitware_vtk_js_Common_Core_DataArray__WEBPACK_IMPORTED_MODULE_1__/* ["default"].newInstance */ .Ay.newInstance({
1241
+ values: table,
1242
+ numberOfComponents: 6,
1243
+ }));
1244
+ return cfun;
1245
+ }
1246
+
1247
+
1248
+ /***/ }),
1249
+
1250
+ /***/ 63470:
1251
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1252
+
1253
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1254
+ /* harmony export */ A: () => (/* binding */ decimate)
1255
+ /* harmony export */ });
1256
+ function decimate(list, interleave, offset = 0) {
1257
+ const interleaveIndices = [];
1258
+ for (let i = offset; i < list.length; i += interleave) {
1259
+ interleaveIndices.push(i);
1260
+ }
1261
+ return interleaveIndices;
1262
+ }
1263
+
1264
+
1265
+ /***/ }),
1266
+
1267
+ /***/ 99949:
1268
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1269
+
1270
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1271
+ /* harmony export */ G: () => (/* binding */ deepClone)
1272
+ /* harmony export */ });
1273
+ function deepClone(obj) {
1274
+ if (obj === null || typeof obj !== 'object') {
1275
+ return obj;
1276
+ }
1277
+ if (typeof obj === 'function') {
1278
+ return obj;
1279
+ }
1280
+ if (typeof structuredClone === 'function') {
1281
+ return obj;
1282
+ }
1283
+ if (Array.isArray(obj)) {
1284
+ return obj.map(deepClone);
1285
+ }
1286
+ else {
1287
+ const clonedObj = {};
1288
+ for (const key in obj) {
1289
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
1290
+ clonedObj[key] = deepClone(obj[key]);
1291
+ }
1292
+ }
1293
+ return clonedObj;
1294
+ }
1295
+ }
1296
+
1297
+
1298
+ /***/ }),
1299
+
1300
+ /***/ 20286:
1301
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1302
+
1303
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1304
+ /* harmony export */ A: () => (/* binding */ fnv1aHash)
1305
+ /* harmony export */ });
1306
+ function fnv1aHash(str) {
1307
+ let hash = 0x811c9dc5;
1308
+ for (let i = 0; i < str.length; i++) {
1309
+ hash ^= str.charCodeAt(i);
1310
+ hash +=
1311
+ (hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24);
1312
+ }
1313
+ return (hash >>> 0).toString(36);
1314
+ }
1315
+
1316
+
1317
+ /***/ }),
1318
+
1319
+ /***/ 88619:
1320
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1321
+
1322
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1323
+ /* harmony export */ A: () => (/* binding */ getClosestImageId)
1324
+ /* harmony export */ });
1325
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
1326
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(74876);
1327
+ /* harmony import */ var _getSpacingInNormalDirection__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(85008);
1328
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(19325);
1329
+
1330
+
1331
+
1332
+
1333
+ function getClosestImageId(imageVolume, worldPos, viewPlaneNormal) {
1334
+ const { direction, spacing, imageIds } = imageVolume;
1335
+ if (!imageIds.length) {
1336
+ return;
1337
+ }
1338
+ const kVector = direction.slice(6, 9);
1339
+ const dotProducts = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(kVector, viewPlaneNormal);
1340
+ if (Math.abs(dotProducts) < 1 - _constants__WEBPACK_IMPORTED_MODULE_3__.EPSILON) {
1341
+ return;
1342
+ }
1343
+ const spacingInNormalDirection = (0,_getSpacingInNormalDirection__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A)({ direction, spacing }, viewPlaneNormal);
1344
+ const halfSpacingInNormalDirection = spacingInNormalDirection / 2;
1345
+ let imageIdForTool;
1346
+ for (let i = 0; i < imageIds.length; i++) {
1347
+ const imageId = imageIds[i];
1348
+ const { imagePositionPatient } = _metaData__WEBPACK_IMPORTED_MODULE_1__.get('imagePlaneModule', imageId);
1349
+ const dir = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create();
1350
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.sub */ .eR.sub(dir, worldPos, imagePositionPatient);
1351
+ const dot = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(dir, viewPlaneNormal);
1352
+ if (Math.abs(dot) < halfSpacingInNormalDirection) {
1353
+ imageIdForTool = imageId;
1354
+ }
1355
+ }
1356
+ return imageIdForTool;
1357
+ }
1358
+
1359
+
1360
+ /***/ }),
1361
+
1362
+ /***/ 47476:
1363
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1364
+
1365
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1366
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
1367
+ /* harmony export */ });
1368
+ /* harmony import */ var _getSliceRange__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20537);
1369
+ /* harmony import */ var _getTargetVolumeAndSpacingInNormalDir__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(65292);
1370
+
1371
+
1372
+ function getImageSliceDataForVolumeViewport(viewport) {
1373
+ const camera = viewport.getCamera();
1374
+ const { spacingInNormalDirection, imageVolume } = (0,_getTargetVolumeAndSpacingInNormalDir__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)(viewport, camera);
1375
+ if (!imageVolume) {
1376
+ return;
1377
+ }
1378
+ const { viewPlaneNormal, focalPoint } = camera;
1379
+ const actorEntry = viewport
1380
+ .getActors()
1381
+ .find((a) => a.referencedId === imageVolume.volumeId ||
1382
+ a.uid === imageVolume.volumeId);
1383
+ if (!actorEntry) {
1384
+ console.warn('No actor found for with actorUID of', imageVolume.volumeId);
1385
+ }
1386
+ const volumeActor = actorEntry.actor;
1387
+ const sliceRange = (0,_getSliceRange__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(volumeActor, viewPlaneNormal, focalPoint);
1388
+ const { min, max, current } = sliceRange;
1389
+ const numberOfSlices = Math.round((max - min) / spacingInNormalDirection) + 1;
1390
+ let imageIndex = ((current - min) / (max - min)) * numberOfSlices;
1391
+ imageIndex = Math.floor(imageIndex);
1392
+ if (imageIndex > numberOfSlices - 1) {
1393
+ imageIndex = numberOfSlices - 1;
1394
+ }
1395
+ else if (imageIndex < 0) {
1396
+ imageIndex = 0;
1397
+ }
1398
+ return {
1399
+ numberOfSlices,
1400
+ imageIndex,
1401
+ };
1402
+ }
1403
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (getImageSliceDataForVolumeViewport);
1404
+
1405
+
1406
+ /***/ }),
1407
+
1408
+ /***/ 32173:
1409
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1410
+
1411
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1412
+ /* harmony export */ A: () => (/* binding */ getScalingParameters)
1413
+ /* harmony export */ });
1414
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(74876);
1415
+
1416
+ function getScalingParameters(imageId) {
1417
+ const modalityLutModule = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('modalityLutModule', imageId) || {};
1418
+ const generalSeriesModule = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('generalSeriesModule', imageId) || {};
1419
+ const { modality } = generalSeriesModule;
1420
+ const scalingParameters = {
1421
+ rescaleSlope: modalityLutModule.rescaleSlope || 1,
1422
+ rescaleIntercept: modalityLutModule.rescaleIntercept ?? 0,
1423
+ modality,
1424
+ };
1425
+ const suvFactor = _metaData__WEBPACK_IMPORTED_MODULE_0__.get('scalingModule', imageId) || {};
1426
+ return {
1427
+ ...scalingParameters,
1428
+ ...(modality === 'PT' && {
1429
+ suvbw: suvFactor.suvbw,
1430
+ suvbsa: suvFactor.suvbsa,
1431
+ suvlbm: suvFactor.suvlbm,
1432
+ }),
1433
+ };
1434
+ }
1435
+
1436
+
1437
+ /***/ }),
1438
+
1439
+ /***/ 20537:
1440
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1441
+
1442
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1443
+ /* harmony export */ A: () => (/* binding */ getSliceRange)
1444
+ /* harmony export */ });
1445
+ /* harmony import */ var _kitware_vtk_js_Common_Core_MatrixBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(89265);
1446
+ /* harmony import */ var _getVolumeActorCorners__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(15105);
1447
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(19325);
1448
+
1449
+
1450
+
1451
+ const SMALL_EPSILON = _constants__WEBPACK_IMPORTED_MODULE_2__.EPSILON * _constants__WEBPACK_IMPORTED_MODULE_2__.EPSILON;
1452
+ const isOne = (v) => Math.abs(Math.abs(v) - 1) < SMALL_EPSILON;
1453
+ const isUnit = (v, off) => isOne(v[off]) || isOne(v[off + 1]) || isOne(v[off + 2]);
1454
+ const isOrthonormal = (v) => isUnit(v, 0) && isUnit(v, 3) && isUnit(v, 6);
1455
+ function getSliceRange(volumeActor, viewPlaneNormal, focalPoint) {
1456
+ const imageData = volumeActor.getMapper().getInputData();
1457
+ let corners;
1458
+ const direction = imageData.getDirection();
1459
+ if (isOrthonormal(direction)) {
1460
+ corners = (0,_getVolumeActorCorners__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)(volumeActor);
1461
+ }
1462
+ else {
1463
+ const [dx, dy, dz] = imageData.getDimensions();
1464
+ const cornersIdx = [
1465
+ [0, 0, 0],
1466
+ [dx - 1, 0, 0],
1467
+ [0, dy - 1, 0],
1468
+ [dx - 1, dy - 1, 0],
1469
+ [0, 0, dz - 1],
1470
+ [dx - 1, 0, dz - 1],
1471
+ [0, dy - 1, dz - 1],
1472
+ [dx - 1, dy - 1, dz - 1],
1473
+ ];
1474
+ corners = cornersIdx.map((it) => imageData.indexToWorld(it));
1475
+ }
1476
+ const transform = _kitware_vtk_js_Common_Core_MatrixBuilder__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A
1477
+ .buildFromDegree()
1478
+ .identity()
1479
+ .rotateFromDirections(viewPlaneNormal, [1, 0, 0]);
1480
+ corners.forEach((pt) => transform.apply(pt));
1481
+ const transformedFocalPoint = [...focalPoint];
1482
+ transform.apply(transformedFocalPoint);
1483
+ const currentSlice = transformedFocalPoint[0];
1484
+ let minX = Infinity;
1485
+ let maxX = -Infinity;
1486
+ for (let i = 0; i < 8; i++) {
1487
+ const x = corners[i][0];
1488
+ if (x > maxX) {
1489
+ maxX = x;
1490
+ }
1491
+ if (x < minX) {
1492
+ minX = x;
1493
+ }
1494
+ }
1495
+ return {
1496
+ min: minX,
1497
+ max: maxX,
1498
+ current: currentSlice,
1499
+ actor: volumeActor,
1500
+ viewPlaneNormal,
1501
+ focalPoint,
1502
+ };
1503
+ }
1504
+
1505
+
1506
+ /***/ }),
1507
+
1508
+ /***/ 85008:
1509
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1510
+
1511
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1512
+ /* harmony export */ A: () => (/* binding */ getSpacingInNormalDirection)
1513
+ /* harmony export */ });
1514
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
1515
+
1516
+ function getSpacingInNormalDirection(imageVolume, viewPlaneNormal) {
1517
+ const { direction, spacing } = imageVolume;
1518
+ const iVector = direction.slice(0, 3);
1519
+ const jVector = direction.slice(3, 6);
1520
+ const kVector = direction.slice(6, 9);
1521
+ const dotProducts = [
1522
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(iVector, viewPlaneNormal),
1523
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(jVector, viewPlaneNormal),
1524
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(kVector, viewPlaneNormal),
1525
+ ];
1526
+ const projectedSpacing = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create();
1527
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.set */ .eR.set(projectedSpacing, dotProducts[0] * spacing[0], dotProducts[1] * spacing[1], dotProducts[2] * spacing[2]);
1528
+ const spacingInNormalDirection = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.length */ .eR.length(projectedSpacing);
1529
+ return spacingInNormalDirection;
1530
+ }
1531
+
1532
+
1533
+ /***/ }),
1534
+
1535
+ /***/ 65292:
1536
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1537
+
1538
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1539
+ /* harmony export */ A: () => (/* binding */ getTargetVolumeAndSpacingInNormalDir)
1540
+ /* harmony export */ });
1541
+ /* harmony import */ var _cache_cache__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(49038);
1542
+ /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(19325);
1543
+ /* harmony import */ var _getSpacingInNormalDirection__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(85008);
1544
+ /* harmony import */ var _loaders_volumeLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(39561);
1545
+ /* harmony import */ var _getVolumeId__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(12437);
1546
+
1547
+
1548
+
1549
+
1550
+
1551
+ const EPSILON_PART = 1 + _constants__WEBPACK_IMPORTED_MODULE_1__.EPSILON;
1552
+ const startsWith = (str, starts) => starts === str.substring(0, Math.min(str.length, starts.length));
1553
+ const isPrimaryVolume = (volume) => !!(0,_loaders_volumeLoader__WEBPACK_IMPORTED_MODULE_3__.getVolumeLoaderSchemes)().find((scheme) => startsWith(volume.volumeId, scheme));
1554
+ function getTargetVolumeAndSpacingInNormalDir(viewport, camera, targetId, useSlabThickness = false) {
1555
+ const { viewPlaneNormal } = camera;
1556
+ const volumeActors = viewport.getActors();
1557
+ if (!volumeActors.length) {
1558
+ return {
1559
+ spacingInNormalDirection: null,
1560
+ imageVolume: null,
1561
+ actorUID: null,
1562
+ };
1563
+ }
1564
+ const imageVolumes = volumeActors
1565
+ .map((va) => {
1566
+ const actorUID = va.referencedId ?? va.uid;
1567
+ return _cache_cache__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Ay.getVolume(actorUID);
1568
+ })
1569
+ .filter((iv) => !!iv);
1570
+ if (targetId) {
1571
+ const targetVolumeId = (0,_getVolumeId__WEBPACK_IMPORTED_MODULE_4__/* .getVolumeId */ .A)(targetId);
1572
+ const imageVolumeIndex = imageVolumes.findIndex((iv) => targetVolumeId.includes(iv.volumeId));
1573
+ const imageVolume = imageVolumes[imageVolumeIndex];
1574
+ const { uid: actorUID } = volumeActors[imageVolumeIndex];
1575
+ const spacingInNormalDirection = getSpacingInNormal(imageVolume, viewPlaneNormal, viewport, useSlabThickness);
1576
+ return { imageVolume, spacingInNormalDirection, actorUID };
1577
+ }
1578
+ if (!imageVolumes.length) {
1579
+ return {
1580
+ spacingInNormalDirection: null,
1581
+ imageVolume: null,
1582
+ actorUID: null,
1583
+ };
1584
+ }
1585
+ const smallest = {
1586
+ spacingInNormalDirection: Infinity,
1587
+ imageVolume: null,
1588
+ actorUID: null,
1589
+ };
1590
+ const hasPrimaryVolume = imageVolumes.find(isPrimaryVolume);
1591
+ for (let i = 0; i < imageVolumes.length; i++) {
1592
+ const imageVolume = imageVolumes[i];
1593
+ if (hasPrimaryVolume && !isPrimaryVolume(imageVolume)) {
1594
+ continue;
1595
+ }
1596
+ const spacingInNormalDirection = getSpacingInNormal(imageVolume, viewPlaneNormal, viewport);
1597
+ if (spacingInNormalDirection * EPSILON_PART <
1598
+ smallest.spacingInNormalDirection) {
1599
+ smallest.spacingInNormalDirection = spacingInNormalDirection;
1600
+ smallest.imageVolume = imageVolume;
1601
+ smallest.actorUID = volumeActors[i].uid;
1602
+ }
1603
+ }
1604
+ return smallest;
1605
+ }
1606
+ function getSpacingInNormal(imageVolume, viewPlaneNormal, viewport, useSlabThickness = false) {
1607
+ const { slabThickness } = viewport.getProperties();
1608
+ let spacingInNormalDirection = slabThickness;
1609
+ if (!slabThickness || !useSlabThickness) {
1610
+ spacingInNormalDirection = (0,_getSpacingInNormalDirection__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A)(imageVolume, viewPlaneNormal);
1611
+ }
1612
+ return spacingInNormalDirection;
1613
+ }
1614
+
1615
+
1616
+ /***/ }),
1617
+
1618
+ /***/ 24724:
1619
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1620
+
1621
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1622
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
1623
+ /* harmony export */ });
1624
+ /* harmony import */ var _RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(39536);
1625
+
1626
+ function getViewportsWithVolumeId(volumeId) {
1627
+ const renderingEngines = (0,_RenderingEngine_getRenderingEngine__WEBPACK_IMPORTED_MODULE_0__/* .getRenderingEngines */ .qO)();
1628
+ const targetViewports = [];
1629
+ renderingEngines.forEach((renderingEngine) => {
1630
+ const viewports = renderingEngine.getVolumeViewports();
1631
+ const filteredViewports = viewports.filter((vp) => vp.hasVolumeId(volumeId));
1632
+ targetViewports.push(...filteredViewports);
1633
+ });
1634
+ return targetViewports;
1635
+ }
1636
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (getViewportsWithVolumeId);
1637
+
1638
+
1639
+ /***/ }),
1640
+
1641
+ /***/ 70210:
1642
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1643
+
1644
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1645
+ /* harmony export */ A: () => (/* binding */ getVoiFromSigmoidRGBTransferFunction)
1646
+ /* harmony export */ });
1647
+ function getVoiFromSigmoidRGBTransferFunction(cfun) {
1648
+ let cfunRange = [];
1649
+ const [lower, upper] = cfun.getRange();
1650
+ cfun.getTable(lower, upper, 1024, cfunRange);
1651
+ cfunRange = cfunRange.filter((v, k) => k % 3 === 0);
1652
+ const cfunDomain = [...Array(1024).keys()].map((v, k) => {
1653
+ return lower + ((upper - lower) / (1024 - 1)) * k;
1654
+ });
1655
+ const y1 = cfunRange[256];
1656
+ const logy1 = Math.log((1 - y1) / y1);
1657
+ const x1 = cfunDomain[256];
1658
+ const y2 = cfunRange[256 * 3];
1659
+ const logy2 = Math.log((1 - y2) / y2);
1660
+ const x2 = cfunDomain[256 * 3];
1661
+ const ww = Math.round((4 * (x2 - x1)) / (logy1 - logy2));
1662
+ const wc = Math.round(x1 + (ww * logy1) / 4);
1663
+ return [Math.round(wc - ww / 2), Math.round(wc + ww / 2)];
1664
+ }
1665
+
1666
+
1667
+ /***/ }),
1668
+
1669
+ /***/ 15105:
1670
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1671
+
1672
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1673
+ /* harmony export */ A: () => (/* binding */ getVolumeActorCorners)
1674
+ /* harmony export */ });
1675
+ function getVolumeActorCorners(volumeActor) {
1676
+ const imageData = volumeActor.getMapper().getInputData();
1677
+ const bounds = imageData.extentToBounds(imageData.getExtent());
1678
+ return [
1679
+ [bounds[0], bounds[2], bounds[4]],
1680
+ [bounds[0], bounds[2], bounds[5]],
1681
+ [bounds[0], bounds[3], bounds[4]],
1682
+ [bounds[0], bounds[3], bounds[5]],
1683
+ [bounds[1], bounds[2], bounds[4]],
1684
+ [bounds[1], bounds[2], bounds[5]],
1685
+ [bounds[1], bounds[3], bounds[4]],
1686
+ [bounds[1], bounds[3], bounds[5]],
1687
+ ];
1688
+ }
1689
+
1690
+
1691
+ /***/ }),
1692
+
1693
+ /***/ 12437:
1694
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1695
+
1696
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1697
+ /* harmony export */ A: () => (/* binding */ getVolumeId)
1698
+ /* harmony export */ });
1699
+ const getVolumeId = (targetId) => {
1700
+ const prefix = 'volumeId:';
1701
+ const str = targetId.includes(prefix)
1702
+ ? targetId.substring(prefix.length)
1703
+ : targetId;
1704
+ const index = str.indexOf('sliceIndex=');
1705
+ return index === -1 ? str : str.substring(0, index - 1);
1706
+ };
1707
+
1708
+
1709
+ /***/ }),
1710
+
1711
+ /***/ 4031:
1712
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1713
+
1714
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1715
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
1716
+ /* harmony export */ });
1717
+ /* harmony import */ var _getSliceRange__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(20537);
1718
+ /* harmony import */ var _getTargetVolumeAndSpacingInNormalDir__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(65292);
1719
+
1720
+
1721
+ function getVolumeSliceRangeInfo(viewport, volumeId, useSlabThickness = false) {
1722
+ const camera = viewport.getCamera();
1723
+ const { focalPoint, viewPlaneNormal } = camera;
1724
+ const { spacingInNormalDirection, actorUID } = (0,_getTargetVolumeAndSpacingInNormalDir__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)(viewport, camera, volumeId, useSlabThickness);
1725
+ if (!actorUID) {
1726
+ throw new Error(`Could not find image volume with id ${volumeId} in the viewport`);
1727
+ }
1728
+ const actorEntry = viewport.getActor(actorUID);
1729
+ if (!actorEntry) {
1730
+ console.warn('No actor found for with actorUID of', actorUID);
1731
+ return null;
1732
+ }
1733
+ const volumeActor = actorEntry.actor;
1734
+ const sliceRange = (0,_getSliceRange__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(volumeActor, viewPlaneNormal, focalPoint);
1735
+ return {
1736
+ sliceRange,
1737
+ spacingInNormalDirection,
1738
+ camera,
1739
+ };
1740
+ }
1741
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (getVolumeSliceRangeInfo);
1742
+
1743
+
1744
+ /***/ }),
1745
+
1746
+ /***/ 61375:
1747
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1748
+
1749
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1750
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
1751
+ /* harmony export */ });
1752
+ /* harmony import */ var _getVolumeSliceRangeInfo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4031);
1753
+
1754
+ function getVolumeViewportScrollInfo(viewport, volumeId, useSlabThickness = false) {
1755
+ const { sliceRange, spacingInNormalDirection, camera } = (0,_getVolumeSliceRangeInfo__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(viewport, volumeId, useSlabThickness);
1756
+ const { min, max, current } = sliceRange;
1757
+ const numScrollSteps = Math.round((max - min) / spacingInNormalDirection);
1758
+ const fraction = (current - min) / (max - min);
1759
+ const floatingStepNumber = fraction * numScrollSteps;
1760
+ const currentStepIndex = Math.round(floatingStepNumber);
1761
+ return {
1762
+ numScrollSteps,
1763
+ currentStepIndex,
1764
+ sliceRangeInfo: {
1765
+ sliceRange,
1766
+ spacingInNormalDirection,
1767
+ camera,
1768
+ },
1769
+ };
1770
+ }
1771
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (getVolumeViewportScrollInfo);
1772
+
1773
+
1774
+ /***/ }),
1775
+
1776
+ /***/ 30169:
1777
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1778
+
1779
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1780
+ /* harmony export */ a: () => (/* binding */ hasFloatScalingParameters)
1781
+ /* harmony export */ });
1782
+ const hasFloatScalingParameters = (scalingParameters) => {
1783
+ const hasFloatRescale = Object.values(scalingParameters).some((value) => typeof value === 'number' && !Number.isInteger(value));
1784
+ return hasFloatRescale;
1785
+ };
1786
+
1787
+
1788
+ /***/ }),
1789
+
1790
+ /***/ 38883:
1791
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1792
+
1793
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1794
+ /* harmony export */ A: () => (/* binding */ hasNaNValues)
1795
+ /* harmony export */ });
1796
+ function hasNaNValues(input) {
1797
+ if (Array.isArray(input)) {
1798
+ return input.some((value) => Number.isNaN(value));
1799
+ }
1800
+ return Number.isNaN(input);
1801
+ }
1802
+
1803
+
1804
+ /***/ }),
1805
+
1806
+ /***/ 39537:
1807
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1808
+
1809
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1810
+ /* harmony export */ A: () => (/* binding */ imageIdToURI)
1811
+ /* harmony export */ });
1812
+ function imageIdToURI(imageId) {
1813
+ const colonIndex = imageId.indexOf(':');
1814
+ return imageId.substring(colonIndex + 1);
1815
+ }
1816
+
1817
+
1818
+ /***/ }),
1819
+
1820
+ /***/ 17791:
1821
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1822
+
1823
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1824
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
1825
+ /* harmony export */ });
1826
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(74876);
1827
+
1828
+ const retrieveConfigurationState = new Map();
1829
+ const IMAGE_RETRIEVE_CONFIGURATION = 'imageRetrieveConfiguration';
1830
+ const imageRetrieveMetadataProvider = {
1831
+ IMAGE_RETRIEVE_CONFIGURATION,
1832
+ clear: () => {
1833
+ retrieveConfigurationState.clear();
1834
+ },
1835
+ add: (key, payload) => {
1836
+ retrieveConfigurationState.set(key, payload);
1837
+ },
1838
+ clone: () => {
1839
+ return new Map(retrieveConfigurationState);
1840
+ },
1841
+ restore: (state) => {
1842
+ retrieveConfigurationState.clear();
1843
+ state.forEach((value, key) => {
1844
+ retrieveConfigurationState.set(key, value);
1845
+ });
1846
+ },
1847
+ get: (type, ...queries) => {
1848
+ if (type === IMAGE_RETRIEVE_CONFIGURATION) {
1849
+ return queries
1850
+ .map((query) => retrieveConfigurationState.get(query))
1851
+ .find((it) => it !== undefined);
1852
+ }
1853
+ },
1854
+ };
1855
+ (0,_metaData__WEBPACK_IMPORTED_MODULE_0__.addProvider)(imageRetrieveMetadataProvider.get.bind(imageRetrieveMetadataProvider));
1856
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (imageRetrieveMetadataProvider);
1857
+
1858
+
1859
+ /***/ }),
1860
+
1861
+ /***/ 50134:
1862
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1863
+
1864
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1865
+ /* harmony export */ A: () => (/* binding */ invertRgbTransferFunction)
1866
+ /* harmony export */ });
1867
+ function invertRgbTransferFunction(rgbTransferFunction) {
1868
+ if (!rgbTransferFunction) {
1869
+ return;
1870
+ }
1871
+ const size = rgbTransferFunction.getSize();
1872
+ for (let index = 0; index < size; index++) {
1873
+ const nodeValue1 = [];
1874
+ rgbTransferFunction.getNodeValue(index, nodeValue1);
1875
+ nodeValue1[1] = 1 - nodeValue1[1];
1876
+ nodeValue1[2] = 1 - nodeValue1[2];
1877
+ nodeValue1[3] = 1 - nodeValue1[3];
1878
+ rgbTransferFunction.setNodeValue(index, nodeValue1);
1879
+ }
1880
+ }
1881
+
1882
+
1883
+ /***/ }),
1884
+
1885
+ /***/ 1865:
1886
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1887
+
1888
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1889
+ /* harmony export */ A: () => (/* binding */ makeVolumeMetadata)
1890
+ /* harmony export */ });
1891
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(74876);
1892
+
1893
+ function makeVolumeMetadata(imageIds) {
1894
+ const imageId0 = imageIds[0];
1895
+ const { pixelRepresentation, bitsAllocated, bitsStored, highBit, photometricInterpretation, samplesPerPixel, } = (0,_metaData__WEBPACK_IMPORTED_MODULE_0__.get)('imagePixelModule', imageId0);
1896
+ const voiLut = [];
1897
+ const voiLutModule = (0,_metaData__WEBPACK_IMPORTED_MODULE_0__.get)('voiLutModule', imageId0);
1898
+ let voiLUTFunction;
1899
+ if (voiLutModule) {
1900
+ const { windowWidth, windowCenter } = voiLutModule;
1901
+ voiLUTFunction = voiLutModule?.voiLUTFunction;
1902
+ if (Array.isArray(windowWidth)) {
1903
+ for (let i = 0; i < windowWidth.length; i++) {
1904
+ voiLut.push({
1905
+ windowWidth: windowWidth[i],
1906
+ windowCenter: windowCenter[i],
1907
+ });
1908
+ }
1909
+ }
1910
+ else {
1911
+ voiLut.push({
1912
+ windowWidth: windowWidth,
1913
+ windowCenter: windowCenter,
1914
+ });
1915
+ }
1916
+ }
1917
+ else {
1918
+ voiLut.push({
1919
+ windowWidth: undefined,
1920
+ windowCenter: undefined,
1921
+ });
1922
+ }
1923
+ const { modality, seriesInstanceUID } = (0,_metaData__WEBPACK_IMPORTED_MODULE_0__.get)('generalSeriesModule', imageId0);
1924
+ const { imageOrientationPatient, pixelSpacing, frameOfReferenceUID, columns, rows, } = (0,_metaData__WEBPACK_IMPORTED_MODULE_0__.get)('imagePlaneModule', imageId0);
1925
+ return {
1926
+ BitsAllocated: bitsAllocated,
1927
+ BitsStored: bitsStored,
1928
+ SamplesPerPixel: samplesPerPixel,
1929
+ HighBit: highBit,
1930
+ PhotometricInterpretation: photometricInterpretation,
1931
+ PixelRepresentation: pixelRepresentation,
1932
+ Modality: modality,
1933
+ ImageOrientationPatient: imageOrientationPatient,
1934
+ PixelSpacing: pixelSpacing,
1935
+ FrameOfReferenceUID: frameOfReferenceUID,
1936
+ Columns: columns,
1937
+ Rows: rows,
1938
+ voiLut,
1939
+ VOILUTFunction: voiLUTFunction,
1940
+ SeriesInstanceUID: seriesInstanceUID,
1941
+ };
1942
+ }
1943
+
1944
+
1945
+ /***/ }),
1946
+
1947
+ /***/ 56577:
1948
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
1949
+
1950
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1951
+ /* harmony export */ X6: () => (/* binding */ iterateOverPointsInShapeVoxelManager),
1952
+ /* harmony export */ ii: () => (/* binding */ pointInShapeCallback)
1953
+ /* harmony export */ });
1954
+ /* unused harmony export iterateOverPointsInShape */
1955
+ /* harmony import */ var _createPositionCallback__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(87784);
1956
+
1957
+ function pointInShapeCallback(imageData, options) {
1958
+ const { pointInShapeFn, callback, boundsIJK, returnPoints = false } = options;
1959
+ let scalarData;
1960
+ if (imageData.getScalarData) {
1961
+ scalarData = imageData.getScalarData();
1962
+ }
1963
+ else {
1964
+ const scalars = imageData.getPointData().getScalars();
1965
+ if (scalars) {
1966
+ scalarData = scalars.getData();
1967
+ }
1968
+ else {
1969
+ const { voxelManager } = imageData.get('voxelManager') || {};
1970
+ if (voxelManager) {
1971
+ scalarData = voxelManager.getCompleteScalarDataArray();
1972
+ }
1973
+ }
1974
+ }
1975
+ const dimensions = imageData.getDimensions();
1976
+ const defaultBoundsIJK = [
1977
+ [0, dimensions[0]],
1978
+ [0, dimensions[1]],
1979
+ [0, dimensions[2]],
1980
+ ];
1981
+ const bounds = boundsIJK || defaultBoundsIJK;
1982
+ const pointsInShape = iterateOverPointsInShape({
1983
+ imageData,
1984
+ bounds,
1985
+ scalarData,
1986
+ pointInShapeFn,
1987
+ callback,
1988
+ });
1989
+ return returnPoints ? pointsInShape : undefined;
1990
+ }
1991
+ function iterateOverPointsInShape({ imageData, bounds, scalarData, pointInShapeFn, callback, }) {
1992
+ const [[iMin, iMax], [jMin, jMax], [kMin, kMax]] = bounds;
1993
+ const { numComps } = imageData;
1994
+ const dimensions = imageData.getDimensions();
1995
+ const indexToWorld = (0,_createPositionCallback__WEBPACK_IMPORTED_MODULE_0__/* .createPositionCallback */ .P)(imageData);
1996
+ const pointIJK = [0, 0, 0];
1997
+ const xMultiple = numComps ||
1998
+ scalarData.length / dimensions[2] / dimensions[1] / dimensions[0];
1999
+ const yMultiple = dimensions[0] * xMultiple;
2000
+ const zMultiple = dimensions[1] * yMultiple;
2001
+ const pointsInShape = [];
2002
+ for (let k = kMin; k <= kMax; k++) {
2003
+ pointIJK[2] = k;
2004
+ const indexK = k * zMultiple;
2005
+ for (let j = jMin; j <= jMax; j++) {
2006
+ pointIJK[1] = j;
2007
+ const indexJK = indexK + j * yMultiple;
2008
+ for (let i = iMin; i <= iMax; i++) {
2009
+ pointIJK[0] = i;
2010
+ const pointLPS = indexToWorld(pointIJK);
2011
+ if (pointInShapeFn(pointLPS, pointIJK)) {
2012
+ const index = indexJK + i * xMultiple;
2013
+ let value;
2014
+ if (xMultiple > 2) {
2015
+ value = [
2016
+ scalarData[index],
2017
+ scalarData[index + 1],
2018
+ scalarData[index + 2],
2019
+ ];
2020
+ }
2021
+ else {
2022
+ value = scalarData[index];
2023
+ }
2024
+ pointsInShape.push({
2025
+ value,
2026
+ index,
2027
+ pointIJK,
2028
+ pointLPS: pointLPS.slice(),
2029
+ });
2030
+ callback({ value, index, pointIJK, pointLPS });
2031
+ }
2032
+ }
2033
+ }
2034
+ }
2035
+ return pointsInShape;
2036
+ }
2037
+ function iterateOverPointsInShapeVoxelManager({ voxelManager, bounds, imageData, pointInShapeFn, callback, returnPoints, }) {
2038
+ const [[iMin, iMax], [jMin, jMax], [kMin, kMax]] = bounds;
2039
+ const indexToWorld = (0,_createPositionCallback__WEBPACK_IMPORTED_MODULE_0__/* .createPositionCallback */ .P)(imageData);
2040
+ const pointIJK = [0, 0, 0];
2041
+ const pointsInShape = [];
2042
+ for (let k = kMin; k <= kMax; k++) {
2043
+ pointIJK[2] = k;
2044
+ for (let j = jMin; j <= jMax; j++) {
2045
+ pointIJK[1] = j;
2046
+ for (let i = iMin; i <= iMax; i++) {
2047
+ pointIJK[0] = i;
2048
+ const pointLPS = indexToWorld(pointIJK);
2049
+ if (pointInShapeFn(pointLPS, pointIJK)) {
2050
+ const index = voxelManager.toIndex(pointIJK);
2051
+ const value = voxelManager.getAtIndex(index);
2052
+ if (returnPoints) {
2053
+ pointsInShape.push({
2054
+ value,
2055
+ index,
2056
+ pointIJK: [...pointIJK],
2057
+ pointLPS: pointLPS.slice(),
2058
+ });
2059
+ }
2060
+ callback?.({ value, index, pointIJK, pointLPS });
2061
+ }
2062
+ }
2063
+ }
2064
+ }
2065
+ return pointsInShape;
2066
+ }
2067
+
2068
+
2069
+ /***/ }),
2070
+
2071
+ /***/ 80500:
2072
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2073
+
2074
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2075
+ /* harmony export */ A: () => (/* binding */ snapFocalPointToSlice)
2076
+ /* harmony export */ });
2077
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
2078
+
2079
+ function snapFocalPointToSlice(focalPoint, position, sliceRange, viewPlaneNormal, spacingInNormalDirection, deltaFrames) {
2080
+ const { min, max, current } = sliceRange;
2081
+ const posDiffFromFocalPoint = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create();
2082
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.sub */ .eR.sub(posDiffFromFocalPoint, position, focalPoint);
2083
+ const steps = Math.round((max - min) / spacingInNormalDirection);
2084
+ const fraction = (current - min) / (max - min);
2085
+ const floatingStepNumber = fraction * steps;
2086
+ let frameIndex = Math.round(floatingStepNumber);
2087
+ let newFocalPoint = [
2088
+ focalPoint[0] -
2089
+ viewPlaneNormal[0] * floatingStepNumber * spacingInNormalDirection,
2090
+ focalPoint[1] -
2091
+ viewPlaneNormal[1] * floatingStepNumber * spacingInNormalDirection,
2092
+ focalPoint[2] -
2093
+ viewPlaneNormal[2] * floatingStepNumber * spacingInNormalDirection,
2094
+ ];
2095
+ frameIndex += deltaFrames;
2096
+ if (frameIndex > steps) {
2097
+ frameIndex = steps;
2098
+ }
2099
+ else if (frameIndex < 0) {
2100
+ frameIndex = 0;
2101
+ }
2102
+ const newSlicePosFromMin = frameIndex * spacingInNormalDirection;
2103
+ newFocalPoint = [
2104
+ newFocalPoint[0] + viewPlaneNormal[0] * newSlicePosFromMin,
2105
+ newFocalPoint[1] + viewPlaneNormal[1] * newSlicePosFromMin,
2106
+ newFocalPoint[2] + viewPlaneNormal[2] * newSlicePosFromMin,
2107
+ ];
2108
+ const newPosition = [
2109
+ newFocalPoint[0] + posDiffFromFocalPoint[0],
2110
+ newFocalPoint[1] + posDiffFromFocalPoint[1],
2111
+ newFocalPoint[2] + posDiffFromFocalPoint[2],
2112
+ ];
2113
+ return { newFocalPoint, newPosition };
2114
+ }
2115
+
2116
+
2117
+ /***/ }),
2118
+
2119
+ /***/ 90537:
2120
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2121
+
2122
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2123
+ /* harmony export */ A: () => (/* binding */ sortImageIdsAndGetSpacing)
2124
+ /* harmony export */ });
2125
+ /* harmony import */ var gl_matrix__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40230);
2126
+ /* harmony import */ var _metaData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(74876);
2127
+ /* harmony import */ var _calculateSpacingBetweenImageIds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(42384);
2128
+
2129
+
2130
+
2131
+ function sortImageIdsAndGetSpacing(imageIds, scanAxisNormal) {
2132
+ const { imagePositionPatient: referenceImagePositionPatient, imageOrientationPatient, } = _metaData__WEBPACK_IMPORTED_MODULE_1__.get('imagePlaneModule', imageIds[0]);
2133
+ if (!scanAxisNormal) {
2134
+ const rowCosineVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.fromValues */ .eR.fromValues(imageOrientationPatient[0], imageOrientationPatient[1], imageOrientationPatient[2]);
2135
+ const colCosineVec = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.fromValues */ .eR.fromValues(imageOrientationPatient[3], imageOrientationPatient[4], imageOrientationPatient[5]);
2136
+ scanAxisNormal = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create();
2137
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.cross */ .eR.cross(scanAxisNormal, rowCosineVec, colCosineVec);
2138
+ }
2139
+ const usingWadoUri = imageIds[0].split(':')[0] === 'wadouri';
2140
+ const zSpacing = (0,_calculateSpacingBetweenImageIds__WEBPACK_IMPORTED_MODULE_2__/* ["default"] */ .A)(imageIds);
2141
+ let sortedImageIds;
2142
+ function getDistance(imageId) {
2143
+ const { imagePositionPatient } = _metaData__WEBPACK_IMPORTED_MODULE_1__.get('imagePlaneModule', imageId);
2144
+ const positionVector = gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.create */ .eR.create();
2145
+ gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.sub */ .eR.sub(positionVector, referenceImagePositionPatient, imagePositionPatient);
2146
+ return gl_matrix__WEBPACK_IMPORTED_MODULE_0__/* .vec3.dot */ .eR.dot(positionVector, scanAxisNormal);
2147
+ }
2148
+ if (!usingWadoUri) {
2149
+ const distanceImagePairs = imageIds.map((imageId) => {
2150
+ const distance = getDistance(imageId);
2151
+ return {
2152
+ distance,
2153
+ imageId,
2154
+ };
2155
+ });
2156
+ distanceImagePairs.sort((a, b) => b.distance - a.distance);
2157
+ sortedImageIds = distanceImagePairs.map((a) => a.imageId);
2158
+ }
2159
+ else {
2160
+ const prefetchedImageIds = [
2161
+ imageIds[0],
2162
+ imageIds[Math.floor(imageIds.length / 2)],
2163
+ ];
2164
+ sortedImageIds = imageIds;
2165
+ const firstImageDistance = getDistance(prefetchedImageIds[0]);
2166
+ const middleImageDistance = getDistance(prefetchedImageIds[1]);
2167
+ if (firstImageDistance - middleImageDistance < 0) {
2168
+ sortedImageIds.reverse();
2169
+ }
2170
+ }
2171
+ const { imagePositionPatient: origin } = _metaData__WEBPACK_IMPORTED_MODULE_1__.get('imagePlaneModule', sortedImageIds[0]);
2172
+ const result = {
2173
+ zSpacing,
2174
+ origin,
2175
+ sortedImageIds,
2176
+ };
2177
+ return result;
2178
+ }
2179
+
2180
+
2181
+ /***/ }),
2182
+
2183
+ /***/ 51919:
2184
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2185
+
2186
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2187
+ /* harmony export */ e: () => (/* binding */ transformCanvasToIJK)
2188
+ /* harmony export */ });
2189
+ /* harmony import */ var _transformWorldToIndex__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(38669);
2190
+
2191
+ function transformCanvasToIJK(viewport, canvasPoint) {
2192
+ const { imageData: vtkImageData } = viewport.getImageData();
2193
+ const worldPoint = viewport.canvasToWorld(canvasPoint);
2194
+ return (0,_transformWorldToIndex__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .A)(vtkImageData, worldPoint);
2195
+ }
2196
+
2197
+
2198
+ /***/ }),
2199
+
2200
+ /***/ 94741:
2201
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2202
+
2203
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2204
+ /* harmony export */ A: () => (/* binding */ transformIndexToWorld)
2205
+ /* harmony export */ });
2206
+ function transformIndexToWorld(imageData, voxelPos) {
2207
+ return imageData.indexToWorld(voxelPos);
2208
+ }
2209
+
2210
+
2211
+ /***/ }),
2212
+
2213
+ /***/ 45278:
2214
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
2215
+
2216
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2217
+ /* harmony export */ J: () => (/* binding */ updateVTKImageDataWithCornerstoneImage)
2218
+ /* harmony export */ });
2219
+ function updateVTKImageDataWithCornerstoneImage(sourceImageData, image) {
2220
+ const pixelData = image.voxelManager.getScalarData();
2221
+ if (!sourceImageData.getPointData) {
2222
+ return;
2223
+ }
2224
+ const scalarData = sourceImageData
2225
+ .getPointData()
2226
+ .getScalars()
2227
+ .getData();
2228
+ if (image.color && image.rgba) {
2229
+ const newPixelData = new Uint8Array(image.columns * image.rows * 3);
2230
+ for (let i = 0; i < image.columns * image.rows; i++) {
2231
+ newPixelData[i * 3] = pixelData[i * 4];
2232
+ newPixelData[i * 3 + 1] = pixelData[i * 4 + 1];
2233
+ newPixelData[i * 3 + 2] = pixelData[i * 4 + 2];
2234
+ }
2235
+ image.rgba = false;
2236
+ image.getPixelData = () => newPixelData;
2237
+ scalarData.set(newPixelData);
2238
+ }
2239
+ else {
2240
+ scalarData.set(pixelData);
2241
+ }
2242
+ sourceImageData.modified();
2243
+ }
2244
+
2245
+
2246
+
2247
+ /***/ })
2248
+
2249
+ }]);