@ohif/app 3.14.0-beta.72 → 3.14.0-beta.73

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 (45) hide show
  1. package/dist/{2894.bundle.770d3d9e.js → 1153.bundle.efd8a415.js} +3129 -166
  2. package/dist/{1566.bundle.e9f5d851.js → 1566.bundle.d58db206.js} +47 -9
  3. package/dist/{1645.bundle.1a86b10e.js → 1645.bundle.a8ee81ea.js} +73 -20
  4. package/dist/{1793.bundle.7b6d510f.js → 1793.bundle.27458a55.js} +2 -2
  5. package/dist/{1862.bundle.10bed54a.js → 1862.bundle.79bfe469.js} +1 -1
  6. package/dist/{2717.bundle.4167aa16.js → 2717.bundle.e4bad54f.js} +2 -2
  7. package/dist/{2748.bundle.a90b290d.js → 2748.bundle.eaa94e2e.js} +0 -805
  8. package/dist/{513.bundle.9c0548cf.js → 2894.bundle.d612efb2.js} +1 -1
  9. package/dist/{3004.bundle.cbd2e499.js → 3004.bundle.c6734d77.js} +2 -2
  10. package/dist/3723.bundle.eab70100.js +808 -0
  11. package/dist/{3771.bundle.1c9e74f3.js → 3771.bundle.6cb07c14.js} +2 -2
  12. package/dist/{4500.bundle.79728db8.js → 4449.bundle.3e4b07e6.js} +1043 -69
  13. package/dist/{4606.bundle.05282205.js → 4606.bundle.a2a1aa34.js} +1 -1
  14. package/dist/{5076.bundle.157252dd.js → 5076.bundle.95c07142.js} +50 -8
  15. package/dist/{5143.bundle.1ddc3eb4.js → 5143.bundle.2ea0b15d.js} +1145 -134
  16. package/dist/{5320.bundle.43308cb4.js → 5320.bundle.335efd86.js} +247 -210
  17. package/dist/{5914.bundle.00f408d2.js → 5914.bundle.f6e9fc4a.js} +37 -9
  18. package/dist/{5989.bundle.6da1ff18.js → 5989.bundle.2999d206.js} +320 -231
  19. package/dist/{213.bundle.6bbe580b.js → 6133.bundle.d4f7403f.js} +3062 -117
  20. package/dist/{3386.bundle.bdaa8014.js → 6289.bundle.2795699d.js} +95 -26
  21. package/dist/{6847.bundle.7fd47a86.js → 6847.bundle.5a087332.js} +27 -4
  22. package/dist/{7604.bundle.2d399cf0.js → 7604.bundle.e703a54d.js} +1 -1
  23. package/dist/{7464.bundle.36e9c349.js → 8037.bundle.8b5f4114.js} +2753 -495
  24. package/dist/{8699.bundle.c00d7ae1.js → 8699.bundle.024fb1bc.js} +2 -2
  25. package/dist/{9187.bundle.134a42b2.js → 9187.bundle.7d18bb1c.js} +2 -2
  26. package/dist/{9481.bundle.65162f9d.js → 9481.bundle.f443c81b.js} +2 -2
  27. package/dist/{9620.bundle.e098e167.js → 9620.bundle.24273cf3.js} +2 -2
  28. package/dist/{9886.bundle.5c1ff898.js → 9886.bundle.cabb4a24.js} +2 -2
  29. package/dist/{9892.bundle.fe68e426.js → 9892.bundle.9bc28476.js} +2 -2
  30. package/dist/{9948.bundle.29548cec.js → 9948.bundle.b4ff610d.js} +2 -2
  31. package/dist/app-config.js +2 -0
  32. package/dist/{app.bundle.58791784.js → app.bundle.220fbf72.js} +38 -38
  33. package/dist/{compute.bundle.09be4c13.js → compute.bundle.19cf1283.js} +10 -10
  34. package/dist/customizations/gpu/high-texture-4096.jsonc +9 -0
  35. package/dist/customizations/gpu/high.jsonc +8 -0
  36. package/dist/customizations/gpu/low-tablet.jsonc +7 -0
  37. package/dist/customizations/gpu/low.jsonc +7 -0
  38. package/dist/customizations/gpu/medium.jsonc +7 -0
  39. package/dist/customizations/index.html +39 -0
  40. package/dist/{histogram-worker.bundle.a8bb873a.js → histogram-worker.bundle.58e60d7c.js} +4 -4
  41. package/dist/index.html +1 -1
  42. package/dist/{interpolation.bundle.1eeebcfe.js → interpolation.bundle.7b3850e6.js} +7 -7
  43. package/dist/{polySeg.bundle.5bc24361.js → polySeg.bundle.157e1e17.js} +11 -11
  44. package/dist/sw.js +1 -1
  45. package/package.json +6 -6
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- (globalThis["rspackChunk_ohif_app"] ||= []).push([[4500], {
2
+ (globalThis["rspackChunk_ohif_app"] ||= []).push([[4449], {
3
3
  23172(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4
4
  /**
5
5
  * Common utilities
@@ -89,16 +89,21 @@ class TiledRenderingEngine extends _BaseRenderingEngine_js__rspack_import_0/* ["
89
89
  super(id);
90
90
  this._renderFlaggedViewports = () => {
91
91
  this._throwIfDestroyed();
92
+ const renderStart = performance.now();
92
93
  if (this.offscreenMultiRenderWindow) {
93
94
  this.performVtkDrawCall();
94
95
  }
95
96
  const viewports = this._getViewportsAsArray();
96
97
  const eventDetailArray = [];
98
+ const renderedViewports = [];
97
99
  for (let i = 0; i < viewports.length; i++) {
98
100
  const viewport = viewports[i];
99
101
  if (this._needsRender.has(viewport.id)) {
100
102
  const eventDetail = this.renderViewportUsingCustomOrVtkPipeline(viewport);
101
- eventDetailArray.push(eventDetail);
103
+ if (!this._waitsForStorage(viewport, renderStart)) {
104
+ eventDetailArray.push(eventDetail);
105
+ renderedViewports.push(viewport);
106
+ }
102
107
  viewport.setRendered();
103
108
  this._needsRender.delete(viewport.id);
104
109
  if (this._needsRender.size === 0) {
@@ -114,6 +119,7 @@ class TiledRenderingEngine extends _BaseRenderingEngine_js__rspack_import_0/* ["
114
119
  }
115
120
  (0,_utilities_triggerEvent_js__rspack_import_3/* ["default"] */.A)(eventDetail.element, _enums_Events_js__rspack_import_1/* ["default"].IMAGE_RENDERED */.A.IMAGE_RENDERED, eventDetail);
116
121
  });
122
+ this._notifyFidelityOfRenderedViewports(renderedViewports);
117
123
  };
118
124
  if (!this.useCPURendering) {
119
125
  this.ensureOffscreenResources();
@@ -393,13 +399,36 @@ __webpack_require__.d(__webpack_exports__, {
393
399
  /* import */ var _kitware_vtk_js_Common_DataModel_ImageData_js__rspack_import_0 = __webpack_require__(41698);
394
400
  /* import */ var _utilities_imageIdToURI_js__rspack_import_1 = __webpack_require__(60465);
395
401
  /* import */ var _utilities_VoxelManager_js__rspack_import_2 = __webpack_require__(60719);
396
- /* import */ var _RenderingEngine_vtkClasses_index_js__rspack_import_3 = __webpack_require__(44418);
397
- /* import */ var _cache_js__rspack_import_4 = __webpack_require__(73998);
402
+ /* import */ var _utilities_CompositeVoxelManager_js__rspack_import_3 = __webpack_require__(86998);
403
+ /* import */ var _volumeTextureStore_js__rspack_import_4 = __webpack_require__(82340);
404
+ /* import */ var _utilities_voxelGrid_index_js__rspack_import_5 = __webpack_require__(49617);
405
+ /* import */ var _RenderingEngine_vtkClasses_index_js__rspack_import_6 = __webpack_require__(44418);
406
+ /* import */ var _enums_ImageQualityStatus_js__rspack_import_7 = __webpack_require__(7330);
407
+ /* import */ var _enums_VoxelStatistics_js__rspack_import_8 = __webpack_require__(10475);
408
+ /* import */ var _enums_Events_js__rspack_import_9 = __webpack_require__(33635);
409
+ /* import */ var _eventTarget_js__rspack_import_10 = __webpack_require__(45340);
410
+ /* import */ var _utilities_triggerEvent_js__rspack_import_11 = __webpack_require__(84444);
411
+ /* import */ var _cache_js__rspack_import_12 = __webpack_require__(73998);
412
+ /* import */ var _utilities_logger_js__rspack_import_13 = __webpack_require__(34040);
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
398
422
 
399
423
 
400
424
 
401
425
 
402
426
 
427
+ const log = _utilities_logger_js__rspack_import_13.coreLog.getLogger('cache', 'ImageVolume');
428
+ const FULL_RESOLUTION_TEXTURE_SET = 'full-resolution/full-extent';
429
+ function markSlice(slot, slice) {
430
+ slot.texture.setUpdatedFrame(slice);
431
+ }
403
432
  class ImageVolume {
404
433
  get numTimePoints() {
405
434
  return typeof this.numDimensionGroups === 'number'
@@ -412,7 +441,7 @@ class ImageVolume {
412
441
  this.cornerstoneImageMetaData = null;
413
442
  this.isPreScaled = false;
414
443
  this.numFrames = null;
415
- const { imageIds, scaling, dimensions, spacing, origin, direction, dataType, volumeId, referencedVolumeId, metadata, referencedImageIds, additionalDetails, voxelManager, numberOfComponents, } = props;
444
+ const { imageIds, scaling, dimensions, spacing, origin, direction, dataType, volumeId, referencedVolumeId, metadata, referencedImageIds, additionalDetails, voxelManager, numberOfComponents, reductionStatistic, } = props;
416
445
  if (!dataType) {
417
446
  throw new Error('Data type is required, please provide a data type as string such as "Uint8Array", "Float32Array", etc.');
418
447
  }
@@ -426,13 +455,13 @@ class ImageVolume {
426
455
  this.origin = origin;
427
456
  this.direction = direction;
428
457
  this.dataType = dataType;
458
+ this.reductionStatistic = reductionStatistic;
459
+ this._numberOfComponents = numberOfComponents || 1;
429
460
  this.hasPixelSpacing =
430
461
  Number.isFinite(spacing[0]) &&
431
462
  spacing[0] > 0 &&
432
463
  Number.isFinite(spacing[1]) &&
433
464
  spacing[1] > 0;
434
- this.vtkOpenGLTexture = _RenderingEngine_vtkClasses_index_js__rspack_import_3/* .vtkStreamingOpenGLTexture.newInstance */.uT.newInstance();
435
- this.vtkOpenGLTexture.setVolumeId(volumeId);
436
465
  this.voxelManager =
437
466
  voxelManager ??
438
467
  _utilities_VoxelManager_js__rspack_import_2/* ["default"].createImageVolumeVoxelManager */.A.createImageVolumeVoxelManager({
@@ -440,6 +469,7 @@ class ImageVolume {
440
469
  imageIds,
441
470
  numberOfComponents,
442
471
  id: volumeId,
472
+ dataType,
443
473
  });
444
474
  this.numVoxels =
445
475
  this.dimensions[0] * this.dimensions[1] * this.dimensions[2];
@@ -478,6 +508,153 @@ class ImageVolume {
478
508
  get sizeInBytes() {
479
509
  return this.voxelManager.sizeInBytes;
480
510
  }
511
+ get voxelGrid() {
512
+ return {
513
+ origin: [...this.origin],
514
+ direction: [...this.direction],
515
+ spacing: [...this.spacing],
516
+ dimensions: [...this.dimensions],
517
+ };
518
+ }
519
+ deliveredRegions() {
520
+ return undefined;
521
+ }
522
+ get reductionStatistic() {
523
+ return this._reductionStatistic;
524
+ }
525
+ set reductionStatistic(statistic) {
526
+ if (statistic === this._reductionStatistic) {
527
+ return;
528
+ }
529
+ const effective = statistic ?? _enums_VoxelStatistics_js__rspack_import_8/* ["default"].Average */.A.Average;
530
+ const reducedWithAnother = this.textureSets.some((set) => set.name !== FULL_RESOLUTION_TEXTURE_SET && set.statistic !== effective);
531
+ if (reducedWithAnother) {
532
+ log.warn(`reductionStatistic of ${this.volumeId} changed to ${statistic} after a reduction with another statistic; existing reduced textures do not match it.`);
533
+ }
534
+ this._reductionStatistic = statistic;
535
+ }
536
+ resetCompositeVoxelManager() {
537
+ this._compositeVoxelManager = undefined;
538
+ }
539
+ get compositeVoxelManager() {
540
+ const primary = this.voxelManager;
541
+ if (!this._compositeVoxelManager ||
542
+ this._compositeVoxelManager.primary !== primary) {
543
+ const delivered = this.deliveredRegions();
544
+ this._compositeVoxelManager = new _utilities_CompositeVoxelManager_js__rspack_import_3/* ["default"] */.Ay({
545
+ primary,
546
+ grid: this.voxelGrid,
547
+ delivered,
548
+ quality: delivered === undefined
549
+ ? _enums_ImageQualityStatus_js__rspack_import_7/* ["default"].FULL_RESOLUTION */.A.FULL_RESOLUTION
550
+ : undefined,
551
+ id: `composite-${this.volumeId}`,
552
+ });
553
+ }
554
+ return this._compositeVoxelManager;
555
+ }
556
+ getVoxelRepresentations() {
557
+ return this.compositeVoxelManager.getRepresentations();
558
+ }
559
+ selectVoxelRepresentation(selector = {}) {
560
+ return this.compositeVoxelManager.selectRepresentation(selector);
561
+ }
562
+ getVoxelQuality(selector = {}) {
563
+ return this.compositeVoxelManager.getQuality(selector);
564
+ }
565
+ getGridQuality(grid, statistic) {
566
+ return this.compositeVoxelManager.getGridQuality(grid, { statistic });
567
+ }
568
+ static get textureBytesUsed() {
569
+ return _volumeTextureStore_js__rspack_import_4/* ["default"].bytesUsed */.Ay.bytesUsed;
570
+ }
571
+ static get textureBudget() {
572
+ return _volumeTextureStore_js__rspack_import_4/* ["default"].budget */.Ay.budget;
573
+ }
574
+ static setTextureBudget(bytes) {
575
+ _volumeTextureStore_js__rspack_import_4/* ["default"].setBudget */.Ay.setBudget(bytes);
576
+ (0,_utilities_triggerEvent_js__rspack_import_11/* ["default"] */.A)(_eventTarget_js__rspack_import_10/* ["default"] */.A, _enums_Events_js__rspack_import_9/* ["default"].VOLUME_TEXTURE_LIMITS_CHANGED */.A.VOLUME_TEXTURE_LIMITS_CHANGED);
577
+ }
578
+ static clearTextureSets() {
579
+ _volumeTextureStore_js__rspack_import_4/* ["default"].clear */.Ay.clear();
580
+ }
581
+ get textureSets() {
582
+ return _volumeTextureStore_js__rspack_import_4/* ["default"].setsOfVolume */.Ay.setsOfVolume(this.volumeId);
583
+ }
584
+ getTextureSet(name) {
585
+ return _volumeTextureStore_js__rspack_import_4/* ["default"].getSet */.Ay.getSet(this.volumeId, name);
586
+ }
587
+ provisionTextureSet(options) {
588
+ return _volumeTextureStore_js__rspack_import_4/* ["default"].provision */.Ay.provision({
589
+ volumeId: this.volumeId,
590
+ volumeGrid: this.voxelGrid,
591
+ dataType: this.dataType,
592
+ numberOfComponents: this._numberOfComponents,
593
+ createTexture: ({ grid, statistic }) => {
594
+ const texture = _RenderingEngine_vtkClasses_index_js__rspack_import_6/* .vtkStreamingOpenGLTexture.newInstance */.uT.newInstance();
595
+ texture.setVolumeId(this.volumeId);
596
+ texture.setGrid(grid);
597
+ texture.setStatistic(statistic);
598
+ return texture;
599
+ },
600
+ destroyTexture: (texture) => {
601
+ texture.releaseGraphicsResources();
602
+ texture.delete();
603
+ },
604
+ applyGrid: (texture, grid) => {
605
+ texture.setGrid(grid);
606
+ texture.markAllFramesUpdated();
607
+ },
608
+ markTextureSlice: markSlice,
609
+ ...options,
610
+ });
611
+ }
612
+ claimTextureSet(name) {
613
+ return _volumeTextureStore_js__rspack_import_4/* ["default"].claim */.Ay.claim(this.volumeId, name);
614
+ }
615
+ releaseTextureSet(name) {
616
+ return _volumeTextureStore_js__rspack_import_4/* ["default"].release */.Ay.release(this.volumeId, name);
617
+ }
618
+ getFullResolutionTexture() {
619
+ if (this.vtkOpenGLTexture) {
620
+ return this.vtkOpenGLTexture;
621
+ }
622
+ this.provisionTextureSet({
623
+ name: FULL_RESOLUTION_TEXTURE_SET,
624
+ grids: [this.voxelGrid],
625
+ coverage: 'full-extent',
626
+ backstop: true,
627
+ });
628
+ return this.vtkOpenGLTexture;
629
+ }
630
+ get vtkOpenGLTexture() {
631
+ const member = this.getTextureSet(FULL_RESOLUTION_TEXTURE_SET)?.members()[0];
632
+ return member?.texture;
633
+ }
634
+ markFrameTexturesDirty(frameIndex) {
635
+ this.voxelManager?.invalidateSlice?.(frameIndex);
636
+ for (const set of this.textureSets) {
637
+ set.markDirty((0,_utilities_voxelGrid_index_js__rspack_import_5.boundsOfFrame)(this.voxelGrid, frameIndex), markSlice);
638
+ }
639
+ }
640
+ recordFrameDelivery(frameIndex, quality) {
641
+ this.compositeVoxelManager.acceptData({
642
+ grid: this.voxelGrid,
643
+ frameIndex,
644
+ quality,
645
+ });
646
+ }
647
+ markFrameModified(frameIndex) {
648
+ this.markFrameTexturesDirty(frameIndex);
649
+ }
650
+ markAllTexturesDirty() {
651
+ for (const set of this.textureSets) {
652
+ set.markAllDirty(markSlice);
653
+ }
654
+ }
655
+ getImageQuality(_imageIdIndex) {
656
+ return _enums_ImageQualityStatus_js__rspack_import_7/* ["default"].FULL_RESOLUTION */.A.FULL_RESOLUTION;
657
+ }
481
658
  get imageIds() {
482
659
  return this._imageIds;
483
660
  }
@@ -515,22 +692,20 @@ class ImageVolume {
515
692
  this.imageData.delete();
516
693
  this.imageData = null;
517
694
  this.voxelManager.clear();
518
- this.vtkOpenGLTexture.releaseGraphicsResources();
519
- this.vtkOpenGLTexture.delete();
695
+ this.resetCompositeVoxelManager();
696
+ _volumeTextureStore_js__rspack_import_4/* ["default"].evictVolume */.Ay.evictVolume(this.volumeId);
520
697
  }
521
698
  invalidate() {
522
- for (let i = 0; i < this.imageIds.length; i++) {
523
- this.vtkOpenGLTexture.setUpdatedFrame(i);
524
- }
699
+ this.markAllTexturesDirty();
525
700
  this.imageData.modified();
526
701
  }
527
702
  modified() {
528
703
  this.imageData.modified();
529
- this.vtkOpenGLTexture.modified();
704
+ this.markAllTexturesDirty();
530
705
  this.numFrames = this._getNumFrames();
531
706
  }
532
707
  removeFromCache() {
533
- _cache_js__rspack_import_4/* ["default"].removeVolumeLoadObject */.Ay.removeVolumeLoadObject(this.volumeId);
708
+ _cache_js__rspack_import_12/* ["default"].removeVolumeLoadObject */.Ay.removeVolumeLoadObject(this.volumeId);
534
709
  }
535
710
  getScalarDataLength() {
536
711
  return this.voxelManager.getScalarDataLength();
@@ -547,14 +722,16 @@ class ImageVolume {
547
722
  getCornerstoneImages() {
548
723
  const { imageIds } = this;
549
724
  return imageIds.map((imageId) => {
550
- return _cache_js__rspack_import_4/* ["default"].getImage */.Ay.getImage(imageId);
725
+ return _cache_js__rspack_import_12/* ["default"].getImage */.Ay.getImage(imageId);
551
726
  });
552
727
  }
553
728
  }
554
- /* export default */ __webpack_exports__.A = (ImageVolume);
729
+ /* export default */ __webpack_exports__.Ay = (ImageVolume);
555
730
 
556
731
  __webpack_require__.d(__webpack_exports__, {
557
- Q: () => (ImageVolume)
732
+ QV: () => (ImageVolume)
733
+ }, {
734
+ gl: FULL_RESOLUTION_TEXTURE_SET
558
735
  });
559
736
 
560
737
 
@@ -1002,10 +1179,12 @@ __webpack_require__.d(__webpack_exports__, {
1002
1179
  /* import */ var _cache_cache_js__rspack_import_0 = __webpack_require__(73998);
1003
1180
  /* import */ var _enums_index_js__rspack_import_1 = __webpack_require__(71088);
1004
1181
  /* import */ var gl_matrix__rspack_import_2 = __webpack_require__(50341);
1005
- /* import */ var _RLEVoxelMap_js__rspack_import_3 = __webpack_require__(71325);
1006
- /* import */ var _isEqual_js__rspack_import_4 = __webpack_require__(3886);
1007
- /* import */ var _pointInShapeCallback_js__rspack_import_5 = __webpack_require__(87169);
1008
- /* import */ var _logger_js__rspack_import_6 = __webpack_require__(34040);
1182
+ /* import */ var _getBufferConfiguration_js__rspack_import_3 = __webpack_require__(25752);
1183
+ /* import */ var _RLEVoxelMap_js__rspack_import_4 = __webpack_require__(71325);
1184
+ /* import */ var _isEqual_js__rspack_import_5 = __webpack_require__(3886);
1185
+ /* import */ var _pointInShapeCallback_js__rspack_import_6 = __webpack_require__(87169);
1186
+ /* import */ var _logger_js__rspack_import_7 = __webpack_require__(34040);
1187
+
1009
1188
 
1010
1189
 
1011
1190
 
@@ -1013,7 +1192,7 @@ __webpack_require__.d(__webpack_exports__, {
1013
1192
 
1014
1193
 
1015
1194
 
1016
- const log = _logger_js__rspack_import_6.coreLog.getLogger('utilities', 'VoxelManager');
1195
+ const log = _logger_js__rspack_import_7.coreLog.getLogger('utilities', 'VoxelManager');
1017
1196
  const DEFAULT_RLE_SIZE = 5 * 1024;
1018
1197
  const worldToIndexDeltaScratch = [0, 0, 0];
1019
1198
  const worldToIndexResultScratch = [0, 0, 0];
@@ -1080,7 +1259,7 @@ class VoxelManager {
1080
1259
  const kMax = Math.max(isInObjectBoundsIJK[2][0], isInObjectBoundsIJK[2][1]);
1081
1260
  const pointsInShape = [];
1082
1261
  if (useLPSTransform) {
1083
- const pointsInShape = (0,_pointInShapeCallback_js__rspack_import_5/* .iterateOverPointsInShapeVoxelManager */.X6)({
1262
+ const pointsInShape = (0,_pointInShapeCallback_js__rspack_import_6/* .iterateOverPointsInShapeVoxelManager */.X6)({
1084
1263
  voxelManager: this,
1085
1264
  imageData: options.imageData,
1086
1265
  bounds: [
@@ -1095,7 +1274,7 @@ class VoxelManager {
1095
1274
  return pointsInShape;
1096
1275
  }
1097
1276
  if (this.map) {
1098
- if (this.map instanceof _RLEVoxelMap_js__rspack_import_3/* ["default"] */.A) {
1277
+ if (this.map instanceof _RLEVoxelMap_js__rspack_import_4/* ["default"] */.A) {
1099
1278
  return this.rleForEach(callback, options);
1100
1279
  }
1101
1280
  for (const index of this.map.keys()) {
@@ -1143,6 +1322,10 @@ class VoxelManager {
1143
1322
  }
1144
1323
  };
1145
1324
  this.getSliceData = ({ sliceIndex, slicePlane, }) => {
1325
+ const direct = this._getSliceData?.({ sliceIndex, slicePlane });
1326
+ if (direct) {
1327
+ return direct;
1328
+ }
1146
1329
  const [width, height, depth] = this.dimensions;
1147
1330
  const frameSize = width * height;
1148
1331
  const startIndex = sliceIndex * frameSize;
@@ -1305,7 +1488,7 @@ class VoxelManager {
1305
1488
  }
1306
1489
  setFromScalarData(scalarData) {
1307
1490
  const map = this.map;
1308
- if (map instanceof _RLEVoxelMap_js__rspack_import_3/* ["default"] */.A) {
1491
+ if (map instanceof _RLEVoxelMap_js__rspack_import_4/* ["default"] */.A) {
1309
1492
  const [width, height, depth] = this.dimensions;
1310
1493
  const sparseValue = (map.defaultValue ?? 0);
1311
1494
  map.clear();
@@ -1346,7 +1529,7 @@ class VoxelManager {
1346
1529
  if (Constructor?.BYTES_PER_ELEMENT) {
1347
1530
  return Constructor.BYTES_PER_ELEMENT;
1348
1531
  }
1349
- if (this.map instanceof _RLEVoxelMap_js__rspack_import_3/* ["default"] */.A) {
1532
+ if (this.map instanceof _RLEVoxelMap_js__rspack_import_4/* ["default"] */.A) {
1350
1533
  const ExpansionConstructor = this.map.pixelDataConstructor
1351
1534
  ? this.map.pixelDataConstructor
1352
1535
  : Uint8ClampedArray;
@@ -1372,7 +1555,10 @@ class VoxelManager {
1372
1555
  return this.scalarData.constructor;
1373
1556
  }
1374
1557
  if (this._getConstructor) {
1375
- return this._getConstructor();
1558
+ const Constructor = this._getConstructor();
1559
+ if (Constructor) {
1560
+ return Constructor;
1561
+ }
1376
1562
  }
1377
1563
  log.warn('No scalar data available or can be used to get the constructor');
1378
1564
  return Float32Array;
@@ -1535,7 +1721,7 @@ class VoxelManager {
1535
1721
  _id: id || '_createRGBScalarVolumeVoxelManager',
1536
1722
  _set: (index, v) => {
1537
1723
  index *= 3;
1538
- const isChanged = !(0,_isEqual_js__rspack_import_4/* ["default"] */.Ay)(scalarData[index], v);
1724
+ const isChanged = !(0,_isEqual_js__rspack_import_5/* ["default"] */.Ay)(scalarData[index], v);
1539
1725
  scalarData[index++] = v[0];
1540
1726
  scalarData[index++] = v[1];
1541
1727
  scalarData[index++] = v[2];
@@ -1549,22 +1735,53 @@ class VoxelManager {
1549
1735
  };
1550
1736
  return voxels;
1551
1737
  }
1552
- static createImageVolumeVoxelManager({ dimensions, imageIds, numberOfComponents = 1, id, }) {
1553
- const pixelsPerSlice = dimensions[0] * dimensions[1];
1554
- const depth = dimensions[2];
1738
+ static createImageVolumeVoxelManager({ dimensions, imageIds, numberOfComponents = 1, id, dataType, }) {
1739
+ const [width, height, depth] = dimensions;
1740
+ const pixelsPerSlice = width * height;
1555
1741
  const sliceVoxelManagers = new Array(depth);
1742
+ const sliceMissGenerations = new Array(depth);
1556
1743
  let lastSliceIndex = -1;
1557
1744
  let lastSliceVoxelManager = null;
1558
1745
  const warnedMissingImageIds = new Set();
1559
1746
  const warnedMissingImages = new Set();
1747
+ const sliceScalings = new Array(depth);
1748
+ const scalingsBySize = new Map();
1749
+ const scalingFor = (imageWidth, imageHeight) => {
1750
+ const key = `${imageWidth}x${imageHeight}`;
1751
+ const cached = scalingsBySize.get(key);
1752
+ if (cached) {
1753
+ return cached;
1754
+ }
1755
+ const columns = new Int32Array(width);
1756
+ const rows = new Int32Array(height);
1757
+ for (let i = 0; i < width; i++) {
1758
+ columns[i] =
1759
+ width > 1 ? Math.floor((i * (imageWidth - 1)) / (width - 1)) : 0;
1760
+ }
1761
+ for (let j = 0; j < height; j++) {
1762
+ const row = height > 1 ? Math.floor((j * (imageHeight - 1)) / (height - 1)) : 0;
1763
+ rows[j] = row * imageWidth;
1764
+ }
1765
+ const scaling = { columns, rows };
1766
+ scalingsBySize.set(key, scaling);
1767
+ return scaling;
1768
+ };
1769
+ const scaleIndex = (scaling, pixelIndex) => {
1770
+ const row = Math.floor(pixelIndex / width);
1771
+ return scaling.rows[row] + scaling.columns[pixelIndex - row * width];
1772
+ };
1560
1773
  const resolveSliceVoxelManager = (sliceIndex) => {
1561
1774
  if (sliceIndex < 0 || sliceIndex >= depth) {
1562
1775
  return null;
1563
1776
  }
1564
1777
  const cachedVoxelManager = sliceVoxelManagers[sliceIndex];
1565
- if (cachedVoxelManager !== undefined) {
1778
+ if (cachedVoxelManager) {
1566
1779
  return cachedVoxelManager;
1567
1780
  }
1781
+ if (cachedVoxelManager === null &&
1782
+ sliceMissGenerations[sliceIndex] === _cache_cache_js__rspack_import_0/* ["default"].getImageGeneration */.Ay.getImageGeneration()) {
1783
+ return null;
1784
+ }
1568
1785
  const imageId = imageIds[sliceIndex];
1569
1786
  if (!imageId) {
1570
1787
  if (!warnedMissingImageIds.has(sliceIndex)) {
@@ -1572,36 +1789,51 @@ class VoxelManager {
1572
1789
  log.warn(`ImageId not found for sliceIndex: ${sliceIndex}`);
1573
1790
  }
1574
1791
  sliceVoxelManagers[sliceIndex] = null;
1792
+ sliceMissGenerations[sliceIndex] = _cache_cache_js__rspack_import_0/* ["default"].getImageGeneration */.Ay.getImageGeneration();
1575
1793
  return null;
1576
1794
  }
1577
1795
  const image = _cache_cache_js__rspack_import_0/* ["default"].getImage */.Ay.getImage(imageId);
1578
1796
  if (!image?.voxelManager) {
1579
1797
  if (!warnedMissingImages.has(imageId)) {
1580
1798
  warnedMissingImages.add(imageId);
1581
- log.warn(`Image not found for imageId: ${imageId}`);
1799
+ log.debug(`Image not found for imageId: ${imageId}`);
1582
1800
  }
1801
+ sliceVoxelManagers[sliceIndex] = null;
1802
+ sliceMissGenerations[sliceIndex] = _cache_cache_js__rspack_import_0/* ["default"].getImageGeneration */.Ay.getImageGeneration();
1583
1803
  return null;
1584
1804
  }
1585
1805
  const imageVoxelManager = image.voxelManager;
1806
+ const imageWidth = image.width ?? imageVoxelManager.dimensions?.[0];
1807
+ const imageHeight = image.height ?? imageVoxelManager.dimensions?.[1];
1586
1808
  sliceVoxelManagers[sliceIndex] = imageVoxelManager;
1809
+ sliceScalings[sliceIndex] =
1810
+ imageWidth === width && imageHeight === height
1811
+ ? null
1812
+ : scalingFor(imageWidth, imageHeight);
1587
1813
  return imageVoxelManager;
1588
1814
  };
1815
+ const imageIndexOf = (sliceIndex, pixelIndex) => {
1816
+ const scaling = sliceScalings[sliceIndex];
1817
+ return scaling ? scaleIndex(scaling, pixelIndex) : pixelIndex;
1818
+ };
1589
1819
  function getVoxelValue(index) {
1590
1820
  const sliceIndex = Math.floor(index / pixelsPerSlice);
1591
1821
  if (sliceIndex < 0 || sliceIndex >= depth) {
1592
1822
  return null;
1593
1823
  }
1594
- const imageVoxelManager = sliceIndex === lastSliceIndex
1595
- ? lastSliceVoxelManager
1596
- : resolveSliceVoxelManager(sliceIndex);
1597
- if (!imageVoxelManager) {
1598
- return null;
1824
+ let imageVoxelManager;
1825
+ if (sliceIndex === lastSliceIndex && lastSliceVoxelManager) {
1826
+ imageVoxelManager = lastSliceVoxelManager;
1599
1827
  }
1600
- if (sliceIndex !== lastSliceIndex) {
1828
+ else {
1829
+ imageVoxelManager = resolveSliceVoxelManager(sliceIndex);
1601
1830
  lastSliceIndex = sliceIndex;
1602
1831
  lastSliceVoxelManager = imageVoxelManager;
1603
1832
  }
1604
- const pixelIndex = index - sliceIndex * pixelsPerSlice;
1833
+ if (!imageVoxelManager) {
1834
+ return null;
1835
+ }
1836
+ const pixelIndex = imageIndexOf(sliceIndex, index - sliceIndex * pixelsPerSlice);
1605
1837
  return imageVoxelManager.getAtIndex(pixelIndex);
1606
1838
  }
1607
1839
  function setVoxelValue(index, v) {
@@ -1609,19 +1841,21 @@ class VoxelManager {
1609
1841
  if (sliceIndex < 0 || sliceIndex >= depth) {
1610
1842
  return false;
1611
1843
  }
1612
- const imageVoxelManager = sliceIndex === lastSliceIndex
1613
- ? lastSliceVoxelManager
1614
- : resolveSliceVoxelManager(sliceIndex);
1615
- if (!imageVoxelManager) {
1616
- return false;
1844
+ let imageVoxelManager;
1845
+ if (sliceIndex === lastSliceIndex && lastSliceVoxelManager) {
1846
+ imageVoxelManager = lastSliceVoxelManager;
1617
1847
  }
1618
- if (sliceIndex !== lastSliceIndex) {
1848
+ else {
1849
+ imageVoxelManager = resolveSliceVoxelManager(sliceIndex);
1619
1850
  lastSliceIndex = sliceIndex;
1620
1851
  lastSliceVoxelManager = imageVoxelManager;
1621
1852
  }
1622
- const pixelIndex = index - sliceIndex * pixelsPerSlice;
1853
+ if (!imageVoxelManager) {
1854
+ return false;
1855
+ }
1856
+ const pixelIndex = imageIndexOf(sliceIndex, index - sliceIndex * pixelsPerSlice);
1623
1857
  const currentValue = imageVoxelManager.getAtIndex(pixelIndex);
1624
- const isChanged = !(0,_isEqual_js__rspack_import_4/* ["default"] */.Ay)(v, currentValue);
1858
+ const isChanged = !(0,_isEqual_js__rspack_import_5/* ["default"] */.Ay)(v, currentValue);
1625
1859
  if (!isChanged) {
1626
1860
  return isChanged;
1627
1861
  }
@@ -1630,10 +1864,10 @@ class VoxelManager {
1630
1864
  }
1631
1865
  const _getConstructor = () => {
1632
1866
  const imageVoxelManager = resolveSliceVoxelManager(0);
1633
- if (!imageVoxelManager) {
1634
- return null;
1867
+ if (imageVoxelManager) {
1868
+ return imageVoxelManager.getConstructor();
1635
1869
  }
1636
- return imageVoxelManager.getConstructor();
1870
+ return dataType ? (0,_getBufferConfiguration_js__rspack_import_3/* .getConstructorFromType */.j5)(dataType, false) : null;
1637
1871
  };
1638
1872
  const voxelManager = new VoxelManager(dimensions, {
1639
1873
  _get: getVoxelValue,
@@ -1644,9 +1878,58 @@ class VoxelManager {
1644
1878
  });
1645
1879
  voxelManager.invalidateCache = () => {
1646
1880
  sliceVoxelManagers.fill(undefined);
1881
+ sliceScalings.fill(undefined);
1647
1882
  lastSliceIndex = -1;
1648
1883
  lastSliceVoxelManager = null;
1649
1884
  };
1885
+ voxelManager.invalidateSlice = (sliceIndex) => {
1886
+ if (sliceIndex < 0 || sliceIndex >= depth) {
1887
+ return;
1888
+ }
1889
+ sliceVoxelManagers[sliceIndex] = undefined;
1890
+ sliceScalings[sliceIndex] = undefined;
1891
+ if (lastSliceIndex === sliceIndex) {
1892
+ lastSliceIndex = -1;
1893
+ lastSliceVoxelManager = null;
1894
+ }
1895
+ };
1896
+ voxelManager._getSliceData = ({ sliceIndex, slicePlane }) => {
1897
+ if (slicePlane !== 2) {
1898
+ return undefined;
1899
+ }
1900
+ const imageVoxelManager = resolveSliceVoxelManager(sliceIndex);
1901
+ if (!imageVoxelManager || numberOfComponents !== 1) {
1902
+ return undefined;
1903
+ }
1904
+ const stored = imageVoxelManager.scalarData;
1905
+ const scalarData = stored ??
1906
+ (imageVoxelManager._getScalarData
1907
+ ? imageVoxelManager.getScalarData()
1908
+ : undefined);
1909
+ if (!scalarData) {
1910
+ return undefined;
1911
+ }
1912
+ const scaling = sliceScalings[sliceIndex];
1913
+ if (!scaling) {
1914
+ return (stored ? stored.slice() : scalarData);
1915
+ }
1916
+ const slice = new scalarData.constructor(pixelsPerSlice);
1917
+ for (let j = 0; j < height; j++) {
1918
+ const sourceRow = scaling.rows[j];
1919
+ const targetRow = j * width;
1920
+ for (let i = 0; i < width; i++) {
1921
+ slice[targetRow + i] = scalarData[sourceRow + scaling.columns[i]];
1922
+ }
1923
+ }
1924
+ return slice;
1925
+ };
1926
+ voxelManager._getSliceView = (sliceIndex) => {
1927
+ if (numberOfComponents !== 1) {
1928
+ return undefined;
1929
+ }
1930
+ const scalarData = resolveSliceVoxelManager(sliceIndex)?.scalarData;
1931
+ return sliceScalings[sliceIndex] ? undefined : scalarData;
1932
+ };
1650
1933
  voxelManager.getMiddleSliceData = () => {
1651
1934
  const middleSliceIndex = Math.floor(dimensions[2] / 2);
1652
1935
  return voxelManager.getSliceData({
@@ -1680,13 +1963,9 @@ class VoxelManager {
1680
1963
  }
1681
1964
  return [minValue, maxValue];
1682
1965
  };
1683
- voxelManager._getScalarDataLength = () => {
1684
- const imageVoxelManager = resolveSliceVoxelManager(0);
1685
- if (!imageVoxelManager) {
1686
- return 0;
1687
- }
1688
- return imageVoxelManager.getScalarDataLength() * dimensions[2];
1689
- };
1966
+ voxelManager._getScalarDataLength = () => resolveSliceVoxelManager(0)
1967
+ ? dimensions[0] * dimensions[1] * dimensions[2] * numberOfComponents
1968
+ : 0;
1690
1969
  voxelManager.getCompleteScalarDataArray = () => {
1691
1970
  const ScalarDataConstructor = voxelManager._getConstructor();
1692
1971
  if (!ScalarDataConstructor) {
@@ -1699,7 +1978,9 @@ class VoxelManager {
1699
1978
  const imageVoxelManager = resolveSliceVoxelManager(sliceIndex);
1700
1979
  if (imageVoxelManager) {
1701
1980
  const sliceStart = sliceIndex * sliceSize;
1702
- const pixelData = imageVoxelManager.getScalarData();
1981
+ const pixelData = sliceScalings[sliceIndex]
1982
+ ? voxelManager.getSliceData({ sliceIndex, slicePlane: 2 })
1983
+ : imageVoxelManager.getScalarData();
1703
1984
  if (numberOfComponents === 1) {
1704
1985
  scalarData.set(pixelData, sliceStart);
1705
1986
  }
@@ -1726,13 +2007,14 @@ class VoxelManager {
1726
2007
  const sliceEnd = sliceStart + sliceSize;
1727
2008
  const sliceData = new SliceDataConstructor(sliceSize);
1728
2009
  sliceData.set(scalarData.subarray(sliceStart, sliceEnd));
1729
- if (imageVoxelManager.scalarData) {
2010
+ if (imageVoxelManager.scalarData &&
2011
+ imageVoxelManager.scalarData.length >= sliceSize) {
1730
2012
  imageVoxelManager.scalarData.set(sliceData);
1731
2013
  imageVoxelManager.modifiedSlices.add(sliceIndex);
1732
2014
  }
1733
2015
  else {
1734
2016
  for (let i = 0; i < sliceSize; i++) {
1735
- imageVoxelManager.setAtIndex(i, sliceData[i]);
2017
+ voxelManager.setAtIndex(sliceStart + i, sliceData[i]);
1736
2018
  }
1737
2019
  }
1738
2020
  for (let i = 0; i < sliceData.length; i++) {
@@ -1834,6 +2116,9 @@ class VoxelManager {
1834
2116
  voxelManager.getMiddleSliceData = () => {
1835
2117
  return voxelGroups[activeDimensionGroup].getMiddleSliceData();
1836
2118
  };
2119
+ voxelManager.invalidateSlice = (sliceIndex) => {
2120
+ voxelGroups.forEach((group) => group.invalidateSlice?.(sliceIndex));
2121
+ };
1837
2122
  voxelManager.setTimePoint = (newTimePoint) => {
1838
2123
  log.warn('Warning: setTimePoint is deprecated. Please use setDimensionGroupNumber instead. Note that timePoint is zero-based while dimensionGroupNumber starts at 1.');
1839
2124
  voxelManager.setDimensionGroupNumber(newTimePoint + 1);
@@ -1961,7 +2246,7 @@ class VoxelManager {
1961
2246
  }
1962
2247
  static createRLEHistoryVoxelManager(sourceVoxelManager, id) {
1963
2248
  const { dimensions } = sourceVoxelManager;
1964
- const map = new _RLEVoxelMap_js__rspack_import_3/* ["default"] */.A(dimensions[0], dimensions[1], dimensions[2]);
2249
+ const map = new _RLEVoxelMap_js__rspack_import_4/* ["default"] */.A(dimensions[0], dimensions[1], dimensions[2]);
1965
2250
  const voxelManager = new VoxelManager(dimensions, {
1966
2251
  _get: (index) => map.get(index),
1967
2252
  _set: function (index, v) {
@@ -1979,7 +2264,7 @@ class VoxelManager {
1979
2264
  }
1980
2265
  this.sourceVoxelManager.setAtIndex(index, v);
1981
2266
  },
1982
- _getScalarData: _RLEVoxelMap_js__rspack_import_3/* ["default"].getScalarData */.A.getScalarData,
2267
+ _getScalarData: _RLEVoxelMap_js__rspack_import_4/* ["default"].getScalarData */.A.getScalarData,
1983
2268
  _updateScalarData: (scalarData) => {
1984
2269
  map.updateScalarData(scalarData);
1985
2270
  return scalarData;
@@ -2013,7 +2298,7 @@ class VoxelManager {
2013
2298
  }
2014
2299
  static createRLEVolumeVoxelManager({ dimensions, id, pixelDataConstructor, defaultValue, }) {
2015
2300
  const [width, height, depth] = dimensions;
2016
- const map = new _RLEVoxelMap_js__rspack_import_3/* ["default"] */.A(width, height, depth);
2301
+ const map = new _RLEVoxelMap_js__rspack_import_4/* ["default"] */.A(width, height, depth);
2017
2302
  if (pixelDataConstructor) {
2018
2303
  map.pixelDataConstructor =
2019
2304
  pixelDataConstructor;
@@ -2027,7 +2312,7 @@ class VoxelManager {
2027
2312
  map.set(index, v);
2028
2313
  return true;
2029
2314
  },
2030
- _getScalarData: _RLEVoxelMap_js__rspack_import_3/* ["default"].getScalarData */.A.getScalarData,
2315
+ _getScalarData: _RLEVoxelMap_js__rspack_import_4/* ["default"].getScalarData */.A.getScalarData,
2031
2316
  _getConstructor: pixelDataConstructor
2032
2317
  ? () => map.pixelDataConstructor
2033
2318
  : undefined,
@@ -2425,7 +2710,7 @@ async function convertVolumeToStackViewport({ viewport, options, }) {
2425
2710
  const { background } = options;
2426
2711
  const viewportId = options.viewportId || id;
2427
2712
  const volume = _cache_cache_js__rspack_import_0/* ["default"].getVolume */.Ay.getVolume(volumeViewport.getVolumeId());
2428
- if (!(volume instanceof _cache_classes_ImageVolume_js__rspack_import_1/* .ImageVolume */.Q)) {
2713
+ if (!(volume instanceof _cache_classes_ImageVolume_js__rspack_import_1/* .ImageVolume */.QV)) {
2429
2714
  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.');
2430
2715
  }
2431
2716
  const viewportInput = {
@@ -2866,11 +3151,20 @@ function getBufferConfiguration(targetBufferType, length, options = {}) {
2866
3151
  const numBytes = length * bytesPerElement;
2867
3152
  return { numBytes, TypedArrayConstructor };
2868
3153
  }
3154
+ function volumeTextureBytes(voxelCount, dataType, numberOfComponents = 1) {
3155
+ const values = voxelCount * Math.max(numberOfComponents || 1, 1);
3156
+ if (!dataType) {
3157
+ return values;
3158
+ }
3159
+ return getBufferConfiguration(dataType, values, { isVolumeBuffer: true })
3160
+ .numBytes;
3161
+ }
2869
3162
 
2870
3163
 
2871
3164
  __webpack_require__.d(__webpack_exports__, {
2872
- h: () => (getBufferConfiguration),
2873
- j: () => (getConstructorFromType)
3165
+ Bw: () => (volumeTextureBytes),
3166
+ hI: () => (getBufferConfiguration),
3167
+ j5: () => (getConstructorFromType)
2874
3168
  });
2875
3169
 
2876
3170
 
@@ -2958,7 +3252,8 @@ function getPlaneMetadata(imageId) {
2958
3252
  }
2959
3253
 
2960
3254
  __webpack_require__.d(__webpack_exports__, {
2961
- A: () => (getClosestStackImageIndexForPoint)
3255
+ A: () => (getClosestStackImageIndexForPoint),
3256
+ M: () => (calculateMinimalDistanceForStackViewport)
2962
3257
  });
2963
3258
 
2964
3259
 
@@ -4536,6 +4831,685 @@ __webpack_require__.d(__webpack_exports__, {
4536
4831
  });
4537
4832
 
4538
4833
 
4834
+ },
4835
+ 49617(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
4836
+ // ESM COMPAT FLAG
4837
+ __webpack_require__.r(__webpack_exports__);
4838
+
4839
+ // EXPORTS
4840
+ __webpack_require__.d(__webpack_exports__, {
4841
+ boundsOfFrame: () => (/* reexport */ boundsOfFrame),
4842
+ boundsOfGrid: () => (/* reexport */ boundsOfGrid),
4843
+ boxAverageAtIJK: () => (/* reexport */ boxAverageAtIJK),
4844
+ boxAverageReductionFactors: () => (/* reexport */ boxAverageReductionFactors),
4845
+ boxStatisticAtIJK: () => (/* reexport */ boxStatisticAtIJK),
4846
+ compareVoxelQuality: () => (/* reexport */ compareVoxelQuality),
4847
+ containsBounds: () => (/* reexport */ containsBounds),
4848
+ cornersOfBounds: () => (/* reexport */ cornersOfBounds),
4849
+ createAverageAccumulator: () => (/* reexport */ voxelStatistics/* .createAverageAccumulator */.gU),
4850
+ deriveBoxAverageGrid: () => (/* reexport */ deriveBoxAverageGrid/* .deriveBoxAverageGrid */.y),
4851
+ getVoxelReduction: () => (/* reexport */ getVoxelReduction),
4852
+ getVoxelStatistic: () => (/* reexport */ voxelStatistics/* .getVoxelStatistic */.rf),
4853
+ getVoxelStatistics: () => (/* reexport */ voxelStatistics/* .getVoxelStatistics */.Q6),
4854
+ gridContainsIndex: () => (/* reexport */ gridContainsIndex),
4855
+ gridCoversRegion: () => (/* reexport */ gridCoversRegion),
4856
+ gridIndexToWorld: () => (/* reexport */ gridIndexToWorld),
4857
+ gridWorldToIndex: () => (/* reexport */ gridWorldToIndex),
4858
+ imageQualityStatusOfRecord: () => (/* reexport */ imageQualityStatusOfRecord),
4859
+ intersectBounds: () => (/* reexport */ intersectBounds),
4860
+ isAliasingReduction: () => (/* reexport */ isAliasingReduction),
4861
+ isDefaultSelectionStatistic: () => (/* reexport */ voxelStatistics/* .isDefaultSelectionStatistic */.Yg),
4862
+ isRegisteredVoxelStatistic: () => (/* reexport */ voxelStatistics/* .isRegisteredVoxelStatistic */.tH),
4863
+ largestAxis: () => (/* reexport */ largestAxis),
4864
+ mapBoundsBetweenGrids: () => (/* reexport */ mapBoundsBetweenGrids),
4865
+ mapIndexBetweenGrids: () => (/* reexport */ mapIndexBetweenGrids),
4866
+ mapIndexToNearestVoxel: () => (/* reexport */ mapIndexToNearestVoxel),
4867
+ maxEdgeOfGrid: () => (/* reexport */ maxEdgeOfGrid),
4868
+ normalizedFactors: () => (/* reexport */ reducedDimensions/* .normalizedFactors */.qu),
4869
+ reduceByBoxAverage: () => (/* reexport */ reduceByBoxAverage),
4870
+ reduceByBoxStatistic: () => (/* reexport */ reduceByBoxStatistic),
4871
+ reducedDimensions: () => (/* reexport */ reducedDimensions/* .reducedDimensions */.on),
4872
+ registerVoxelReduction: () => (/* reexport */ registerVoxelReduction),
4873
+ registerVoxelStatistic: () => (/* reexport */ voxelStatistics/* .registerVoxelStatistic */.G7),
4874
+ requireVoxelStatistic: () => (/* reexport */ voxelStatistics/* .requireVoxelStatistic */.Qk),
4875
+ sameBounds: () => (/* reexport */ sameBounds),
4876
+ volumeOfBounds: () => (/* reexport */ volumeOfBounds),
4877
+ voxelCountOfGrid: () => (/* reexport */ voxelCountOfGrid),
4878
+ voxelGridKey: () => (/* reexport */ voxelGridKey/* .voxelGridKey */.oC),
4879
+ voxelGridWithinLimits: () => (/* reexport */ voxelGridWithinLimits),
4880
+ voxelGridsEqual: () => (/* reexport */ voxelGridKey/* .voxelGridsEqual */._I)
4881
+ });
4882
+
4883
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/reducedDimensions.js
4884
+ var reducedDimensions = __webpack_require__(8014);
4885
+ ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/boxAverageReductionFactors.js
4886
+ const DIVISOR_PREFERENCE_MIN_RATIO = 0.9;
4887
+ const WHOLE_FACTOR_MIN_FITTING_EDGE = 1024;
4888
+ function edgeLimitedEdge(sourceEdge, maxEdge) {
4889
+ if (!(maxEdge > 0) || sourceEdge <= maxEdge) {
4890
+ return sourceEdge;
4891
+ }
4892
+ const fitting = Math.max(1, Math.floor(maxEdge));
4893
+ return fitting > WHOLE_FACTOR_MIN_FITTING_EDGE
4894
+ ? Math.ceil(sourceEdge / Math.ceil(sourceEdge / fitting))
4895
+ : fitting;
4896
+ }
4897
+ function largestAxis(dimensions) {
4898
+ let axis = 0;
4899
+ for (let other = 1; other < 3; other++) {
4900
+ if (dimensions[other] > dimensions[axis]) {
4901
+ axis = other;
4902
+ }
4903
+ }
4904
+ return axis;
4905
+ }
4906
+ function preferDivisor(sourceEdge, fitting) {
4907
+ for (let factor = Math.ceil(sourceEdge / fitting); sourceEdge / factor >= DIVISOR_PREFERENCE_MIN_RATIO * fitting; factor++) {
4908
+ if (sourceEdge % factor === 0) {
4909
+ return sourceEdge / factor;
4910
+ }
4911
+ }
4912
+ return fitting;
4913
+ }
4914
+ function boxAverageReductionFactors(dimensions, limits) {
4915
+ const { maxEdge, maxVoxelCount } = limits ?? {};
4916
+ const reduced = dimensions.map((edge) => Math.max(1, edgeLimitedEdge(edge, maxEdge)));
4917
+ if (maxVoxelCount > 0) {
4918
+ while (reduced[0] * reduced[1] * reduced[2] > maxVoxelCount) {
4919
+ const axis = largestAxis(reduced);
4920
+ if (reduced[axis] <= 1) {
4921
+ break;
4922
+ }
4923
+ reduced[axis] -= 1;
4924
+ }
4925
+ }
4926
+ return reduced.map((edge, axis) => edge >= dimensions[axis]
4927
+ ? 1
4928
+ : dimensions[axis] / preferDivisor(dimensions[axis], edge));
4929
+ }
4930
+
4931
+
4932
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/deriveBoxAverageGrid.js
4933
+ var deriveBoxAverageGrid = __webpack_require__(99190);
4934
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/resolveReduction.js
4935
+ var resolveReduction = __webpack_require__(37728);
4936
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/boxSpan.js
4937
+ var boxSpan = __webpack_require__(9844);
4938
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/enums/VoxelStatistics.js
4939
+ var VoxelStatistics = __webpack_require__(10475);
4940
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/voxelStatistics.js
4941
+ var voxelStatistics = __webpack_require__(40210);
4942
+ ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/boxStatistic.js
4943
+
4944
+
4945
+
4946
+
4947
+ function createAccumulators(statistic) {
4948
+ return { definition: (0,voxelStatistics/* .requireVoxelStatistic */.Qk)(statistic), perComponent: [] };
4949
+ }
4950
+ function growAccumulators(accumulators, count) {
4951
+ const { definition, perComponent } = accumulators;
4952
+ while (perComponent.length < count) {
4953
+ perComponent.push(definition.createAccumulator());
4954
+ }
4955
+ }
4956
+ function valueOfBox(source, resolved, accumulators, i, j, k) {
4957
+ const { factors, sourceOffset, sourceEnd } = resolved;
4958
+ const { perComponent } = accumulators;
4959
+ const spanI = (0,boxSpan/* .spanOfBox */.z1)(sourceOffset[0], factors[0], sourceEnd[0], i);
4960
+ const spanJ = (0,boxSpan/* .spanOfBox */.z1)(sourceOffset[1], factors[1], sourceEnd[1], j);
4961
+ const spanK = (0,boxSpan/* .spanOfBox */.z1)(sourceOffset[2], factors[2], sourceEnd[2], k);
4962
+ for (let component = 0; component < perComponent.length; component++) {
4963
+ perComponent[component].reset();
4964
+ }
4965
+ let components = 0;
4966
+ for (let sourceK = spanK.first; sourceK < spanK.end; sourceK++) {
4967
+ const weightK = (0,boxSpan/* .weightInSpan */.Oj)(spanK, sourceK);
4968
+ for (let sourceJ = spanJ.first; sourceJ < spanJ.end; sourceJ++) {
4969
+ const weightJK = weightK * (0,boxSpan/* .weightInSpan */.Oj)(spanJ, sourceJ);
4970
+ for (let sourceI = spanI.first; sourceI < spanI.end; sourceI++) {
4971
+ const weight = weightJK * (0,boxSpan/* .weightInSpan */.Oj)(spanI, sourceI);
4972
+ const value = source.getAtIJK(sourceI, sourceJ, sourceK);
4973
+ if (typeof value === 'number') {
4974
+ if (Number.isFinite(value)) {
4975
+ growAccumulators(accumulators, 1);
4976
+ perComponent[0].add(value, weight);
4977
+ }
4978
+ continue;
4979
+ }
4980
+ if (!value) {
4981
+ continue;
4982
+ }
4983
+ const length = value.length;
4984
+ growAccumulators(accumulators, length);
4985
+ if (length > components) {
4986
+ components = length;
4987
+ }
4988
+ for (let component = 0; component < length; component++) {
4989
+ const componentValue = value[component];
4990
+ if (Number.isFinite(componentValue)) {
4991
+ perComponent[component].add(componentValue, weight);
4992
+ }
4993
+ }
4994
+ }
4995
+ }
4996
+ }
4997
+ if (components === 0) {
4998
+ return perComponent.length === 0 ? undefined : perComponent[0].getValue();
4999
+ }
5000
+ const result = [];
5001
+ for (let component = 0; component < components; component++) {
5002
+ const componentValue = perComponent[component].getValue();
5003
+ if (componentValue === undefined) {
5004
+ return undefined;
5005
+ }
5006
+ result.push(componentValue);
5007
+ }
5008
+ return result;
5009
+ }
5010
+ function roundValue(value) {
5011
+ if (typeof value === 'number') {
5012
+ return Math.round(value);
5013
+ }
5014
+ for (let component = 0; component < value.length; component++) {
5015
+ value[component] = Math.round(value[component]);
5016
+ }
5017
+ return value;
5018
+ }
5019
+ function boxStatisticAtIJK(source, reduction, i, j, k, statistic = VoxelStatistics/* ["default"].Average */.A.Average) {
5020
+ return valueOfBox(source, (0,resolveReduction/* ["default"] */.A)(source, reduction), createAccumulators(statistic), i, j, k);
5021
+ }
5022
+ function boxAverageAtIJK(source, reduction, i, j, k) {
5023
+ return boxStatisticAtIJK(source, reduction, i, j, k, VoxelStatistics/* ["default"].Average */.A.Average);
5024
+ }
5025
+ function reduceByBoxStatistic(source, reduction, target, options = {}) {
5026
+ const { round = true, statistic = VoxelStatistics/* ["default"].Average */.A.Average } = options;
5027
+ const definition = (0,voxelStatistics/* .requireVoxelStatistic */.Qk)(statistic);
5028
+ const sliceWritten = definition.reduceBySlices?.(source, reduction, target, {
5029
+ round,
5030
+ });
5031
+ if (sliceWritten !== undefined) {
5032
+ return sliceWritten;
5033
+ }
5034
+ const accumulators = { definition, perComponent: [] };
5035
+ const resolved = (0,resolveReduction/* ["default"] */.A)(source, reduction);
5036
+ const { dimensions } = resolved;
5037
+ const [targetI, targetJ, targetK] = reduction.targetOffset ?? [0, 0, 0];
5038
+ let written = 0;
5039
+ for (let k = 0; k < dimensions[2]; k++) {
5040
+ for (let j = 0; j < dimensions[1]; j++) {
5041
+ for (let i = 0; i < dimensions[0]; i++) {
5042
+ const value = valueOfBox(source, resolved, accumulators, i, j, k);
5043
+ if (value === undefined) {
5044
+ continue;
5045
+ }
5046
+ target.setAtIJK(targetI + i, targetJ + j, targetK + k, (round ? roundValue(value) : value));
5047
+ written++;
5048
+ }
5049
+ }
5050
+ }
5051
+ return written;
5052
+ }
5053
+ function reduceByBoxAverage(source, reduction, target, options = {}) {
5054
+ return reduceByBoxStatistic(source, reduction, target, {
5055
+ ...options,
5056
+ statistic: VoxelStatistics/* ["default"].Average */.A.Average,
5057
+ });
5058
+ }
5059
+
5060
+
5061
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/enums/ImageQualityStatus.js
5062
+ var ImageQualityStatus = __webpack_require__(7330);
5063
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/enums/VoxelReductions.js
5064
+ var enums_VoxelReductions = __webpack_require__(33170);
5065
+ ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/voxelQuality.js
5066
+
5067
+
5068
+ const reductionDefinitions = new Map();
5069
+ const registeredConstantNames = [];
5070
+ let hasRegisteredCoreVoxelReductions = false;
5071
+ function registerCoreVoxelReductions() {
5072
+ if (hasRegisteredCoreVoxelReductions) {
5073
+ return;
5074
+ }
5075
+ hasRegisteredCoreVoxelReductions = true;
5076
+ registerVoxelReduction({
5077
+ reduction: enums_VoxelReductions/* ["default"].None */.A.None,
5078
+ aliases: false,
5079
+ description: 'The data holds every voxel of its own grid.',
5080
+ });
5081
+ registerVoxelReduction({
5082
+ reduction: enums_VoxelReductions/* ["default"].BoxAverage */.A.BoxAverage,
5083
+ aliases: false,
5084
+ description: 'The mean of the source voxels of one box.',
5085
+ });
5086
+ registerVoxelReduction({
5087
+ reduction: enums_VoxelReductions/* ["default"].BoxForegroundMajority */.A.BoxForegroundMajority,
5088
+ aliases: false,
5089
+ description: 'The majority non-zero label of the source voxels of one box. It reduces labelmaps.',
5090
+ });
5091
+ registerVoxelReduction({
5092
+ reduction: enums_VoxelReductions/* ["default"].Decimation */.A.Decimation,
5093
+ aliases: true,
5094
+ description: 'Every n-th source voxel. It folds the high spatial frequencies into the signal.',
5095
+ });
5096
+ }
5097
+ function registerVoxelReduction({ reduction, name, aliases, description, }) {
5098
+ if (!reduction) {
5099
+ throw new Error('registerVoxelReduction: the definition needs a reduction');
5100
+ }
5101
+ if (reductionDefinitions.has(reduction)) {
5102
+ throw new Error(`Voxel reduction "${reduction}" is already registered`);
5103
+ }
5104
+ if (typeof aliases !== 'boolean') {
5105
+ throw new Error(`Voxel reduction "${reduction}" must state whether it aliases`);
5106
+ }
5107
+ if (name && Object.prototype.hasOwnProperty.call(enums_VoxelReductions/* ["default"] */.A, name)) {
5108
+ throw new Error(`Voxel reduction constant "${String(name)}" already exists`);
5109
+ }
5110
+ reductionDefinitions.set(reduction, { reduction, aliases, description });
5111
+ if (name) {
5112
+ (0,enums_VoxelReductions/* .registerVoxelReductionsConstant */.o)(name, reduction);
5113
+ registeredConstantNames.push(name);
5114
+ }
5115
+ }
5116
+ function getVoxelReduction(reduction) {
5117
+ registerCoreVoxelReductions();
5118
+ return reductionDefinitions.get(reduction);
5119
+ }
5120
+ function isAliasingReduction(reduction) {
5121
+ return getVoxelReduction(reduction)?.aliases !== false;
5122
+ }
5123
+ function __resetVoxelReductionRegistry() {
5124
+ reductionDefinitions.clear();
5125
+ hasRegisteredCoreVoxelReductions = false;
5126
+ for (const name of registeredConstantNames) {
5127
+ delete VoxelReductions[name];
5128
+ }
5129
+ registeredConstantNames.length = 0;
5130
+ }
5131
+ function imageQualityStatusOfRecord(record) {
5132
+ if (record.missing >= record.voxels) {
5133
+ return ImageQualityStatus/* ["default"].FAR_REPLICATE */.A.FAR_REPLICATE;
5134
+ }
5135
+ if (record.missing > 0) {
5136
+ return Math.min(record.lowest ?? ImageQualityStatus/* ["default"].FAR_REPLICATE */.A.FAR_REPLICATE, ImageQualityStatus/* ["default"].ADJACENT_REPLICATE */.A.ADJACENT_REPLICATE);
5137
+ }
5138
+ const lowest = record.lowest ?? ImageQualityStatus/* ["default"].FAR_REPLICATE */.A.FAR_REPLICATE;
5139
+ if (isAliasingReduction(record.reduction)) {
5140
+ return Math.min(lowest, ImageQualityStatus/* ["default"].SUBRESOLUTION */.A.SUBRESOLUTION);
5141
+ }
5142
+ return lowest;
5143
+ }
5144
+ function compareVoxelQuality(record, requirement = {}) {
5145
+ const { displaySpacing, missingAllowed = 0, minStatus } = requirement;
5146
+ const causes = [];
5147
+ let magnitude = 0;
5148
+ if (displaySpacing) {
5149
+ for (let axis = 0; axis < 3; axis++) {
5150
+ const display = displaySpacing[axis];
5151
+ if (!(display > 0)) {
5152
+ continue;
5153
+ }
5154
+ magnitude = Math.max(magnitude, record.grid.spacing[axis] / display);
5155
+ }
5156
+ if (magnitude > 1 + 1e-6) {
5157
+ causes.push('resolution');
5158
+ }
5159
+ }
5160
+ if (isAliasingReduction(record.reduction)) {
5161
+ causes.push('aliasing');
5162
+ }
5163
+ if (record.missing > missingAllowed) {
5164
+ causes.push('missingData');
5165
+ }
5166
+ if (minStatus !== undefined && record.status < minStatus) {
5167
+ causes.push('quality');
5168
+ }
5169
+ return { lossless: causes.length === 0, causes, magnitude, record };
5170
+ }
5171
+
5172
+
5173
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/voxelGridKey.js
5174
+ var voxelGridKey = __webpack_require__(70070);
5175
+ ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/voxelGridTransforms.js
5176
+ function gridIndexToWorld(grid, ijk) {
5177
+ const world = [grid.origin[0], grid.origin[1], grid.origin[2]];
5178
+ for (let axis = 0; axis < 3; axis++) {
5179
+ const distance = ijk[axis] * grid.spacing[axis];
5180
+ world[0] += grid.direction[axis * 3] * distance;
5181
+ world[1] += grid.direction[axis * 3 + 1] * distance;
5182
+ world[2] += grid.direction[axis * 3 + 2] * distance;
5183
+ }
5184
+ return world;
5185
+ }
5186
+ function gridWorldToIndex(grid, world) {
5187
+ const dx = world[0] - grid.origin[0];
5188
+ const dy = world[1] - grid.origin[1];
5189
+ const dz = world[2] - grid.origin[2];
5190
+ const ijk = [0, 0, 0];
5191
+ for (let axis = 0; axis < 3; axis++) {
5192
+ const projection = dx * grid.direction[axis * 3] +
5193
+ dy * grid.direction[axis * 3 + 1] +
5194
+ dz * grid.direction[axis * 3 + 2];
5195
+ ijk[axis] = projection / grid.spacing[axis];
5196
+ }
5197
+ return ijk;
5198
+ }
5199
+ function mapIndexBetweenGrids(source, target, ijk) {
5200
+ return gridWorldToIndex(target, gridIndexToWorld(source, ijk));
5201
+ }
5202
+ function mapIndexToNearestVoxel(source, target, ijk) {
5203
+ const mapped = mapIndexBetweenGrids(source, target, ijk);
5204
+ return [Math.round(mapped[0]), Math.round(mapped[1]), Math.round(mapped[2])];
5205
+ }
5206
+ function gridContainsIndex(grid, ijk) {
5207
+ for (let axis = 0; axis < 3; axis++) {
5208
+ if (ijk[axis] < 0 || ijk[axis] > grid.dimensions[axis] - 1) {
5209
+ return false;
5210
+ }
5211
+ }
5212
+ return true;
5213
+ }
5214
+ function cornersOfBounds(bounds) {
5215
+ const corners = [];
5216
+ for (const i of bounds[0]) {
5217
+ for (const j of bounds[1]) {
5218
+ for (const k of bounds[2]) {
5219
+ corners.push([i, j, k]);
5220
+ }
5221
+ }
5222
+ }
5223
+ return corners;
5224
+ }
5225
+ function gridCoversRegion(source, bounds, target) {
5226
+ const tolerance = 0.5 + 1e-6;
5227
+ for (const corner of cornersOfBounds(bounds)) {
5228
+ const mapped = mapIndexBetweenGrids(source, target, corner);
5229
+ for (let axis = 0; axis < 3; axis++) {
5230
+ if (mapped[axis] < -tolerance ||
5231
+ mapped[axis] > target.dimensions[axis] - 1 + tolerance) {
5232
+ return false;
5233
+ }
5234
+ }
5235
+ }
5236
+ return true;
5237
+ }
5238
+ function mapBoundsBetweenGrids(source, target, bounds) {
5239
+ const tolerance = 1e-6;
5240
+ const faces = [
5241
+ [bounds[0][0] - 0.5, bounds[0][1] + 0.5],
5242
+ [bounds[1][0] - 0.5, bounds[1][1] + 0.5],
5243
+ [bounds[2][0] - 0.5, bounds[2][1] + 0.5],
5244
+ ];
5245
+ const mapped = [
5246
+ [Infinity, -Infinity],
5247
+ [Infinity, -Infinity],
5248
+ [Infinity, -Infinity],
5249
+ ];
5250
+ for (const corner of cornersOfBounds(faces)) {
5251
+ const point = mapIndexBetweenGrids(source, target, corner);
5252
+ for (let axis = 0; axis < 3; axis++) {
5253
+ mapped[axis][0] = Math.min(mapped[axis][0], point[axis]);
5254
+ mapped[axis][1] = Math.max(mapped[axis][1], point[axis]);
5255
+ }
5256
+ }
5257
+ return [
5258
+ [
5259
+ Math.ceil(mapped[0][0] - 0.5 + tolerance),
5260
+ Math.floor(mapped[0][1] + 0.5 - tolerance),
5261
+ ],
5262
+ [
5263
+ Math.ceil(mapped[1][0] - 0.5 + tolerance),
5264
+ Math.floor(mapped[1][1] + 0.5 - tolerance),
5265
+ ],
5266
+ [
5267
+ Math.ceil(mapped[2][0] - 0.5 + tolerance),
5268
+ Math.floor(mapped[2][1] + 0.5 - tolerance),
5269
+ ],
5270
+ ];
5271
+ }
5272
+ function boundsOfGrid(grid) {
5273
+ return [
5274
+ [0, grid.dimensions[0] - 1],
5275
+ [0, grid.dimensions[1] - 1],
5276
+ [0, grid.dimensions[2] - 1],
5277
+ ];
5278
+ }
5279
+ function boundsOfFrame(grid, frameIndex) {
5280
+ return [
5281
+ [0, grid.dimensions[0] - 1],
5282
+ [0, grid.dimensions[1] - 1],
5283
+ [frameIndex, frameIndex],
5284
+ ];
5285
+ }
5286
+ function intersectBounds(a, b) {
5287
+ return [
5288
+ [Math.max(a[0][0], b[0][0]), Math.min(a[0][1], b[0][1])],
5289
+ [Math.max(a[1][0], b[1][0]), Math.min(a[1][1], b[1][1])],
5290
+ [Math.max(a[2][0], b[2][0]), Math.min(a[2][1], b[2][1])],
5291
+ ];
5292
+ }
5293
+ function volumeOfBounds(bounds) {
5294
+ let volume = 1;
5295
+ for (let axis = 0; axis < 3; axis++) {
5296
+ const length = bounds[axis][1] - bounds[axis][0] + 1;
5297
+ if (length <= 0) {
5298
+ return 0;
5299
+ }
5300
+ volume *= length;
5301
+ }
5302
+ return volume;
5303
+ }
5304
+ function containsBounds(outer, inner) {
5305
+ for (let axis = 0; axis < 3; axis++) {
5306
+ if (inner[axis][0] < outer[axis][0] || inner[axis][1] > outer[axis][1]) {
5307
+ return false;
5308
+ }
5309
+ }
5310
+ return true;
5311
+ }
5312
+ function sameBounds(a, b) {
5313
+ for (let axis = 0; axis < 3; axis++) {
5314
+ if (a[axis][0] !== b[axis][0] || a[axis][1] !== b[axis][1]) {
5315
+ return false;
5316
+ }
5317
+ }
5318
+ return true;
5319
+ }
5320
+
5321
+
5322
+ ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/voxelGridSize.js
5323
+ function voxelCountOfGrid(grid) {
5324
+ return grid.dimensions[0] * grid.dimensions[1] * grid.dimensions[2];
5325
+ }
5326
+ function maxEdgeOfGrid(grid) {
5327
+ return Math.max(...grid.dimensions);
5328
+ }
5329
+ function voxelGridWithinLimits(grid, limits) {
5330
+ const { maxEdge, maxVoxelCount } = limits ?? {};
5331
+ if (maxEdge > 0 && maxEdgeOfGrid(grid) > maxEdge) {
5332
+ return false;
5333
+ }
5334
+ if (maxVoxelCount > 0 && voxelCountOfGrid(grid) > maxVoxelCount) {
5335
+ return false;
5336
+ }
5337
+ return true;
5338
+ }
5339
+
5340
+
5341
+ ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/index.js
5342
+
5343
+
5344
+
5345
+
5346
+
5347
+
5348
+
5349
+
5350
+
5351
+
5352
+
5353
+ },
5354
+ 40210(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
5355
+ /* import */ var _enums_VoxelStatistics_js__rspack_import_0 = __webpack_require__(10475);
5356
+ /* import */ var _enums_VoxelReductions_js__rspack_import_1 = __webpack_require__(33170);
5357
+ /* import */ var _sliceReductions_js__rspack_import_2 = __webpack_require__(80365);
5358
+ /* import */ var _averagePlane_js__rspack_import_3 = __webpack_require__(29678);
5359
+ /* import */ var _foregroundMajorityPlane_js__rspack_import_4 = __webpack_require__(12593);
5360
+
5361
+
5362
+
5363
+
5364
+
5365
+ const statisticDefinitions = new Map();
5366
+ const registeredConstantNames = [];
5367
+ let hasRegisteredCoreVoxelStatistics = false;
5368
+ function createAverageAccumulator() {
5369
+ let sum = 0;
5370
+ let count = 0;
5371
+ return {
5372
+ reset: () => {
5373
+ sum = 0;
5374
+ count = 0;
5375
+ },
5376
+ add: (value, weight = 1) => {
5377
+ sum += value * weight;
5378
+ count += weight;
5379
+ },
5380
+ getValue: () => (count === 0 ? undefined : sum / count),
5381
+ };
5382
+ }
5383
+ function createForegroundMajorityAccumulator() {
5384
+ const counts = new Map();
5385
+ let majority;
5386
+ let majorityCount = 0;
5387
+ let sawBackground = false;
5388
+ return {
5389
+ reset: () => {
5390
+ counts.clear();
5391
+ majority = undefined;
5392
+ majorityCount = 0;
5393
+ sawBackground = false;
5394
+ },
5395
+ add: (value, weight = 1) => {
5396
+ if (value === 0) {
5397
+ sawBackground = true;
5398
+ return;
5399
+ }
5400
+ const next = (counts.get(value) ?? 0) + weight;
5401
+ counts.set(value, next);
5402
+ if (next > majorityCount) {
5403
+ majorityCount = next;
5404
+ majority = value;
5405
+ }
5406
+ },
5407
+ getValue: () => {
5408
+ if (majority !== undefined) {
5409
+ return majority;
5410
+ }
5411
+ return sawBackground ? 0 : undefined;
5412
+ },
5413
+ };
5414
+ }
5415
+ function registerCoreVoxelStatistics() {
5416
+ if (hasRegisteredCoreVoxelStatistics) {
5417
+ return;
5418
+ }
5419
+ hasRegisteredCoreVoxelStatistics = true;
5420
+ registerVoxelStatistic({
5421
+ statistic: _enums_VoxelStatistics_js__rspack_import_0/* ["default"].Average */.A.Average,
5422
+ defaultSelection: true,
5423
+ description: 'The mean of the source voxels of one box.',
5424
+ createAccumulator: createAverageAccumulator,
5425
+ reduceBySlices: _sliceReductions_js__rspack_import_2/* .reduceAverageAlongKBySlices */.m,
5426
+ fillPlane: _averagePlane_js__rspack_import_3/* ["default"] */.A,
5427
+ boxReduction: _enums_VoxelReductions_js__rspack_import_1/* ["default"].BoxAverage */.A.BoxAverage,
5428
+ });
5429
+ registerVoxelStatistic({
5430
+ statistic: _enums_VoxelStatistics_js__rspack_import_0/* ["default"].ForegroundMajority */.A.ForegroundMajority,
5431
+ defaultSelection: false,
5432
+ description: 'The majority non-zero label of one box (background ignored unless the box is empty). Used to reduce labelmaps.',
5433
+ createAccumulator: createForegroundMajorityAccumulator,
5434
+ reduceBySlices: _sliceReductions_js__rspack_import_2/* .reduceForegroundMajorityBySlices */.R,
5435
+ fillPlane: _foregroundMajorityPlane_js__rspack_import_4/* ["default"] */.A,
5436
+ boxReduction: _enums_VoxelReductions_js__rspack_import_1/* ["default"].BoxForegroundMajority */.A.BoxForegroundMajority,
5437
+ });
5438
+ }
5439
+ function registerVoxelStatistic({ statistic, name, defaultSelection = false, description, createAccumulator, reduceBySlices, fillPlane, boxReduction, }) {
5440
+ if (!statistic) {
5441
+ throw new Error('registerVoxelStatistic: the definition needs a statistic');
5442
+ }
5443
+ if (statisticDefinitions.has(statistic)) {
5444
+ throw new Error(`Voxel statistic "${statistic}" is already registered`);
5445
+ }
5446
+ if (typeof createAccumulator !== 'function') {
5447
+ throw new Error(`Voxel statistic "${statistic}" must declare a createAccumulator function`);
5448
+ }
5449
+ for (const [field, hook] of Object.entries({ reduceBySlices, fillPlane })) {
5450
+ if (hook !== undefined && typeof hook !== 'function') {
5451
+ throw new Error(`Voxel statistic "${statistic}" declares ${field}, which is not a function`);
5452
+ }
5453
+ }
5454
+ if (name && Object.prototype.hasOwnProperty.call(_enums_VoxelStatistics_js__rspack_import_0/* ["default"] */.A, name)) {
5455
+ throw new Error(`Voxel statistic constant "${String(name)}" already exists`);
5456
+ }
5457
+ statisticDefinitions.set(statistic, {
5458
+ statistic,
5459
+ defaultSelection,
5460
+ description,
5461
+ createAccumulator,
5462
+ reduceBySlices,
5463
+ fillPlane,
5464
+ boxReduction,
5465
+ });
5466
+ if (name) {
5467
+ (0,_enums_VoxelStatistics_js__rspack_import_0/* .registerVoxelStatisticsConstant */.F)(name, statistic);
5468
+ registeredConstantNames.push(name);
5469
+ }
5470
+ }
5471
+ function getVoxelStatistic(statistic) {
5472
+ registerCoreVoxelStatistics();
5473
+ return statisticDefinitions.get(statistic);
5474
+ }
5475
+ function requireVoxelStatistic(statistic) {
5476
+ const definition = getVoxelStatistic(statistic);
5477
+ if (!definition) {
5478
+ throw new Error(`Voxel statistic "${statistic}" is not registered. Call registerVoxelStatistic first.`);
5479
+ }
5480
+ return definition;
5481
+ }
5482
+ function getVoxelStatistics() {
5483
+ registerCoreVoxelStatistics();
5484
+ return [...statisticDefinitions.values()];
5485
+ }
5486
+ function isRegisteredVoxelStatistic(statistic) {
5487
+ return getVoxelStatistic(statistic) !== undefined;
5488
+ }
5489
+ function isDefaultSelectionStatistic(statistic) {
5490
+ return getVoxelStatistic(statistic)?.defaultSelection === true;
5491
+ }
5492
+ function __resetVoxelStatisticRegistry() {
5493
+ statisticDefinitions.clear();
5494
+ hasRegisteredCoreVoxelStatistics = false;
5495
+ for (const name of registeredConstantNames) {
5496
+ delete VoxelStatistics[name];
5497
+ }
5498
+ registeredConstantNames.length = 0;
5499
+ }
5500
+
5501
+
5502
+ __webpack_require__.d(__webpack_exports__, {
5503
+ G7: () => (registerVoxelStatistic),
5504
+ Q6: () => (getVoxelStatistics),
5505
+ Qk: () => (requireVoxelStatistic),
5506
+ Yg: () => (isDefaultSelectionStatistic),
5507
+ gU: () => (createAverageAccumulator),
5508
+ rf: () => (getVoxelStatistic),
5509
+ tH: () => (isRegisteredVoxelStatistic)
5510
+ });
5511
+
5512
+
4539
5513
  },
4540
5514
  67251(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
4541
5515
  /* import */ var gl_matrix__rspack_import_0 = __webpack_require__(50341);