@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,4 +1,4 @@
1
- (globalThis["rspackChunk_ohif_app"] ||= []).push([[213], {
1
+ (globalThis["rspackChunk_ohif_app"] ||= []).push([[6133], {
2
2
  80874(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3
3
  "use strict";
4
4
  /**
@@ -38304,6 +38304,10 @@ class PlanarMountedData {
38304
38304
  if (role && binding.role !== role) {
38305
38305
  continue;
38306
38306
  }
38307
+ if (binding.getActorEntries) {
38308
+ actorEntries.push(...binding.getActorEntries(binding.data));
38309
+ continue;
38310
+ }
38307
38311
  const actorEntry = binding.getActorEntry?.(binding.data);
38308
38312
  if (actorEntry) {
38309
38313
  actorEntries.push(actorEntry);
@@ -38362,8 +38366,14 @@ const PLANAR_PROJECTION_ID = 'planar';
38362
38366
  /* import */ var _init_js__rspack_import_3 = __webpack_require__(90934);
38363
38367
  /* import */ var _metaData_js__rspack_import_4 = __webpack_require__(52284);
38364
38368
  /* import */ var _helpers_renderBackendRegistry_js__rspack_import_5 = __webpack_require__(92117);
38365
- /* import */ var _utilities_isValidVolume_js__rspack_import_6 = __webpack_require__(22750);
38366
- /* import */ var _helpers_getCameraVectors_js__rspack_import_7 = __webpack_require__(22761);
38369
+ /* import */ var _helpers_volumeRenderStrategy_js__rspack_import_6 = __webpack_require__(53703);
38370
+ /* import */ var _utilities_gpuSettingsPresets_js__rspack_import_7 = __webpack_require__(701);
38371
+ /* import */ var _utilities_isValidVolume_js__rspack_import_8 = __webpack_require__(22750);
38372
+ /* import */ var _helpers_getCameraVectors_js__rspack_import_9 = __webpack_require__(22761);
38373
+ /* import */ var _planarVolumeSliceBlendMode_js__rspack_import_10 = __webpack_require__(72813);
38374
+
38375
+
38376
+
38367
38377
 
38368
38378
 
38369
38379
 
@@ -38377,13 +38387,8 @@ class PlanarRenderPathDecisionService {
38377
38387
  if (!dataSet.imageIds.length) {
38378
38388
  throw new Error('[PlanarViewport] Cannot add an empty planar dataset');
38379
38389
  }
38380
- const orientation = options.orientation || _enums_index_js__rspack_import_2.OrientationAxis.ACQUISITION;
38381
- const acquisitionOrientation = getPlanarAcquisitionOrientation(dataSet.imageIds);
38390
+ const { acquisitionOrientation, isAcquisitionPath, useVolumePath } = this.resolvePathInputs(dataSet, options);
38382
38391
  const volumeId = getVolumeId(dataSet);
38383
- const isAcquisitionPath = orientation === _enums_index_js__rspack_import_2.OrientationAxis.ACQUISITION ||
38384
- (acquisitionOrientation !== undefined &&
38385
- orientation === acquisitionOrientation);
38386
- const useVolumePath = isVolumeBackedDataSet(dataSet, isAcquisitionPath);
38387
38392
  if (!isAcquisitionPath &&
38388
38393
  !useVolumePath &&
38389
38394
  !dataSet.useWorldCoordinateImageData) {
@@ -38404,21 +38409,52 @@ class PlanarRenderPathDecisionService {
38404
38409
  if (!dataSet.imageIds.length) {
38405
38410
  return false;
38406
38411
  }
38412
+ const { isAcquisitionPath, useVolumePath } = this.resolvePathInputs(dataSet, options);
38413
+ if (!isAcquisitionPath &&
38414
+ !useVolumePath &&
38415
+ !dataSet.useWorldCoordinateImageData) {
38416
+ return false;
38417
+ }
38418
+ if (useVolumePath && !supportsVolumeRendering(dataSet)) {
38419
+ return false;
38420
+ }
38421
+ return true;
38422
+ }
38423
+ resolvePathInputs(dataSet, options) {
38407
38424
  const orientation = options.orientation || _enums_index_js__rspack_import_2.OrientationAxis.ACQUISITION;
38408
38425
  const acquisitionOrientation = getPlanarAcquisitionOrientation(dataSet.imageIds);
38409
38426
  const isAcquisitionPath = orientation === _enums_index_js__rspack_import_2.OrientationAxis.ACQUISITION ||
38410
38427
  (acquisitionOrientation !== undefined &&
38411
38428
  orientation === acquisitionOrientation);
38412
38429
  const useVolumePath = isVolumeBackedDataSet(dataSet, isAcquisitionPath);
38413
- if (!isAcquisitionPath &&
38414
- !useVolumePath &&
38415
- !dataSet.useWorldCoordinateImageData) {
38430
+ return {
38431
+ acquisitionOrientation,
38432
+ isAcquisitionPath,
38433
+ useVolumePath,
38434
+ };
38435
+ }
38436
+ canDrawAcquiredFrames(dataSet, options) {
38437
+ if (!options.preferAcquiredFrames ||
38438
+ !dataSet.volumeId ||
38439
+ dataSet.useWorldCoordinateImageData) {
38416
38440
  return false;
38417
38441
  }
38418
- if (useVolumePath && !supportsVolumeRendering(dataSet)) {
38442
+ if (options.blendMode !== undefined &&
38443
+ options.blendMode !== _enums_index_js__rspack_import_2.BlendModes.COMPOSITE) {
38419
38444
  return false;
38420
38445
  }
38421
- return true;
38446
+ const volume = _cache_cache_js__rspack_import_1/* ["default"].getVolume */.Ay.getVolume(dataSet.volumeId);
38447
+ if (!volume?.voxelGrid || volume.isDynamicVolume?.()) {
38448
+ return false;
38449
+ }
38450
+ if ((0,_planarVolumeSliceBlendMode_js__rspack_import_10/* .resolveSlabThickness */.tF)(options.slabThickness) > volume.spacing[2]) {
38451
+ return false;
38452
+ }
38453
+ if ((0,_helpers_renderBackendRegistry_js__rspack_import_5/* .getRenderSurfaceForRenderMode */.cg)(this.selectVolumeRenderMode(options)) ===
38454
+ 'cpu') {
38455
+ return false;
38456
+ }
38457
+ return (0,_helpers_volumeRenderStrategy_js__rspack_import_6/* .volumeTextureReductionFactors */.Bs)(volume, (0,_utilities_gpuSettingsPresets_js__rspack_import_7/* .gpuSettingsForRender */.je)()).some((factor) => factor > 1);
38422
38458
  }
38423
38459
  selectImageRenderMode(options) {
38424
38460
  return (0,_helpers_renderBackendRegistry_js__rspack_import_5/* .getRenderModeForBackend */.pI)(this.resolveBackend(options), 'image');
@@ -38448,7 +38484,7 @@ function getPlanarAcquisitionOrientation(imageIds) {
38448
38484
  const colVec = gl_matrix__rspack_import_0/* .vec3.fromValues */.eR.fA(imageOrientationPatient[3], imageOrientationPatient[4], imageOrientationPatient[5]);
38449
38485
  const scanAxisNormal = gl_matrix__rspack_import_0/* .vec3.create */.eR.vt();
38450
38486
  gl_matrix__rspack_import_0/* .vec3.cross */.eR.$A(scanAxisNormal, rowVec, colVec);
38451
- const orientation = (0,_helpers_getCameraVectors_js__rspack_import_7/* .getOrientationFromScanAxisNormal */.sB)([
38487
+ const orientation = (0,_helpers_getCameraVectors_js__rspack_import_9/* .getOrientationFromScanAxisNormal */.sB)([
38452
38488
  scanAxisNormal[0],
38453
38489
  scanAxisNormal[1],
38454
38490
  scanAxisNormal[2],
@@ -38467,7 +38503,7 @@ function hasExplicitCachedVolume(dataSet) {
38467
38503
  return !!(dataSet.volumeId && _cache_cache_js__rspack_import_1/* ["default"].getVolume */.Ay.getVolume(dataSet.volumeId));
38468
38504
  }
38469
38505
  function supportsVolumeRendering(dataSet) {
38470
- return hasExplicitCachedVolume(dataSet) || (0,_utilities_isValidVolume_js__rspack_import_6/* .isValidVolume */.p)(dataSet.imageIds);
38506
+ return hasExplicitCachedVolume(dataSet) || (0,_utilities_isValidVolume_js__rspack_import_8/* .isValidVolume */.p)(dataSet.imageIds);
38471
38507
  }
38472
38508
  function isVolumeBackedDataSet(dataSet, isAcquisitionPath) {
38473
38509
  if (dataSet.useWorldCoordinateImageData) {
@@ -38825,6 +38861,14 @@ var esm = __webpack_require__(50341);
38825
38861
  var types = __webpack_require__(18471);
38826
38862
  // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/getClosestImageId.js
38827
38863
  var getClosestImageId = __webpack_require__(27307);
38864
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/getClosestStackImageIndexForPoint.js
38865
+ var getClosestStackImageIndexForPoint = __webpack_require__(10259);
38866
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/calculateSpacingBetweenImageIds.js
38867
+ var calculateSpacingBetweenImageIds = __webpack_require__(78480);
38868
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/metaData.js
38869
+ var metaData = __webpack_require__(52284);
38870
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/enums/index.js
38871
+ var enums = __webpack_require__(71088);
38828
38872
  // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/imageIdToURI.js
38829
38873
  var utilities_imageIdToURI = __webpack_require__(60465);
38830
38874
  // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/isEqual.js
@@ -39094,6 +39138,11 @@ function getPlanarResolvedViewForReference(args) {
39094
39138
 
39095
39139
 
39096
39140
 
39141
+
39142
+
39143
+
39144
+
39145
+ const PARALLEL_COSINE = 0.99;
39097
39146
  class PlanarViewReferenceController {
39098
39147
  constructor(host) {
39099
39148
  this.host = host;
@@ -39322,8 +39371,42 @@ class PlanarViewReferenceController {
39322
39371
  this.host.setImageIdIndex(viewRef.sliceIndex);
39323
39372
  return true;
39324
39373
  }
39374
+ const closestFrameIndex = this.findClosestFrameIndexOfFocalPoint(referenceContext, viewRef, imageIds);
39375
+ if (typeof closestFrameIndex === 'number') {
39376
+ this.host.setImageIdIndex(closestFrameIndex);
39377
+ return true;
39378
+ }
39325
39379
  return false;
39326
39380
  }
39381
+ findClosestFrameIndexOfFocalPoint(referenceContext, viewRef, imageIds) {
39382
+ const point = viewRef.cameraFocalPoint;
39383
+ if (!point || !imageIds.length) {
39384
+ return;
39385
+ }
39386
+ const stackLike = {
39387
+ getImageIds: () => imageIds,
39388
+ getCurrentImageIdIndex: () => referenceContext.rendering.currentImageIdIndex ?? 0,
39389
+ };
39390
+ const closest = (0,getClosestStackImageIndexForPoint/* .calculateMinimalDistanceForStackViewport */.M)(point, stackLike);
39391
+ if (!closest) {
39392
+ return;
39393
+ }
39394
+ const { index, distance } = closest;
39395
+ const neighbour = imageIds[index + 1] ?? imageIds[index - 1];
39396
+ const spacing = (0,calculateSpacingBetweenImageIds/* ["default"] */.A)(neighbour ? [imageIds[index], neighbour] : [imageIds[index]]);
39397
+ if (distance > spacing) {
39398
+ return;
39399
+ }
39400
+ if (viewRef.viewPlaneNormal) {
39401
+ const { rowCosines, columnCosines } = metaData.get(enums.MetadataModules.IMAGE_PLANE, imageIds[index]);
39402
+ const normal = esm/* .vec3.cross */.eR.$A(esm/* .vec3.create */.eR.vt(), rowCosines, columnCosines);
39403
+ if (Math.abs(esm/* .vec3.dot */.eR.Om(normal, viewRef.viewPlaneNormal)) <
39404
+ PARALLEL_COSINE) {
39405
+ return;
39406
+ }
39407
+ }
39408
+ return index;
39409
+ }
39327
39410
  applyVolumeViewReference(referenceContext, viewRef) {
39328
39411
  const normalizedViewRef = this.normalizeVolumeViewReference(referenceContext, viewRef);
39329
39412
  const resolvedView = this.host
@@ -41001,6 +41084,8 @@ var getImageDataMetadata = __webpack_require__(57804);
41001
41084
  var logger = __webpack_require__(34040);
41002
41085
  // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/GenericViewport/genericViewportDisplaySetAccess.js
41003
41086
  var genericViewportDisplaySetAccess = __webpack_require__(95023);
41087
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/helpers/fidelityIndicator/collectFidelityLines.js
41088
+ var collectFidelityLines = __webpack_require__(91339);
41004
41089
  // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/actorCheck.js
41005
41090
  var actorCheck = __webpack_require__(34455);
41006
41091
  // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/colormap.js
@@ -41184,10 +41269,17 @@ var RenderingEngine_renderPasses = __webpack_require__(82484);
41184
41269
 
41185
41270
 
41186
41271
 
41272
+
41187
41273
 
41188
41274
 
41189
41275
  const log = logger.coreLog.getLogger('RenderingEngine', 'StackViewport');
41190
41276
  class StackViewport extends Viewport/* ["default"] */.A {
41277
+ canReportFidelity() {
41278
+ return true;
41279
+ }
41280
+ collectFidelityLines() {
41281
+ return (0,collectFidelityLines/* .fidelityLineFromStackImage */.a0)(this.csImage);
41282
+ }
41191
41283
  constructor(props) {
41192
41284
  super(props);
41193
41285
  this.imageIds = [];
@@ -43845,6 +43937,8 @@ class VolumeViewport extends BaseVolumeViewport/* ["default"] */.A {
43845
43937
  /* import */ var _utilities_triggerEvent_js__rspack_import_4 = __webpack_require__(84444);
43846
43938
  /* import */ var _utilities_actorCheck_js__rspack_import_5 = __webpack_require__(34455);
43847
43939
  /* import */ var _BaseVolumeViewport_js__rspack_import_6 = __webpack_require__(35915);
43940
+ /* import */ var _helpers_createVolumeMapper_js__rspack_import_7 = __webpack_require__(9891);
43941
+
43848
43942
 
43849
43943
 
43850
43944
 
@@ -43863,15 +43957,10 @@ class VolumeViewport3D extends _BaseVolumeViewport_js__rspack_import_6/* ["defau
43863
43957
  const mapper = actor.getMapper();
43864
43958
  if (mapper && mapper.getInputData) {
43865
43959
  const imageData = mapper.getInputData();
43866
- if (imageData) {
43867
- const spacing = imageData.getSpacing();
43868
- const defaultSampleDistance = (spacing[0] + spacing[1] + spacing[2]) / 6;
43869
- const sampleDistanceMultiplier = multiplier || 1;
43870
- let sampleDistance = defaultSampleDistance * sampleDistanceMultiplier;
43871
- if (sampleDistance !== undefined && mapper.setSampleDistance) {
43872
- const currentSampleDistance = mapper.getSampleDistance();
43873
- mapper.setSampleDistance(sampleDistance);
43874
- }
43960
+ if (imageData && mapper.setSampleDistance) {
43961
+ (0,_helpers_createVolumeMapper_js__rspack_import_7/* .setIdleSampleDistanceMultiplier */.$U)(mapper, multiplier || 1);
43962
+ const texture = mapper.getScalarTexture?.();
43963
+ mapper.setSampleDistance((0,_helpers_createVolumeMapper_js__rspack_import_7/* .sampleDistanceOf */.h6)(imageData, texture, multiplier || 1));
43875
43964
  }
43876
43965
  }
43877
43966
  }
@@ -44078,6 +44167,20 @@ class WebGLContextPool {
44078
44167
  /* export default */ __webpack_exports__.A = (WebGLContextPool);
44079
44168
 
44080
44169
 
44170
+ },
44171
+ 72667(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
44172
+ "use strict";
44173
+ const actorsWaitingForStorage = new WeakMap();
44174
+ function skippedDrawSince(actor, since) {
44175
+ return (actorsWaitingForStorage.get(actor) ?? -Infinity) >= since;
44176
+ }
44177
+ /* export default */ __webpack_exports__.A = (actorsWaitingForStorage);
44178
+
44179
+ __webpack_require__.d(__webpack_exports__, {
44180
+ t: () => (skippedDrawSince)
44181
+ });
44182
+
44183
+
44081
44184
  },
44082
44185
  60696(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
44083
44186
  "use strict";
@@ -46006,10 +46109,14 @@ __webpack_require__.d(__webpack_exports__, {
46006
46109
  /* import */ var _kitware_vtk_js_Rendering_Core_Volume_js__rspack_import_0 = __webpack_require__(51026);
46007
46110
  /* import */ var _loaders_volumeLoader_js__rspack_import_1 = __webpack_require__(66441);
46008
46111
  /* import */ var _createVolumeMapper_js__rspack_import_2 = __webpack_require__(9891);
46009
- /* import */ var _utilities_triggerEvent_js__rspack_import_3 = __webpack_require__(84444);
46010
- /* import */ var _enums_index_js__rspack_import_4 = __webpack_require__(71088);
46011
- /* import */ var _setDefaultVolumeVOI_js__rspack_import_5 = __webpack_require__(26365);
46012
- /* import */ var _init_js__rspack_import_6 = __webpack_require__(90934);
46112
+ /* import */ var _resolveVolumeTexture_js__rspack_import_3 = __webpack_require__(17565);
46113
+ /* import */ var _legacyActorTextureSet_js__rspack_import_4 = __webpack_require__(61719);
46114
+ /* import */ var _utilities_triggerEvent_js__rspack_import_5 = __webpack_require__(84444);
46115
+ /* import */ var _enums_index_js__rspack_import_6 = __webpack_require__(71088);
46116
+ /* import */ var _setDefaultVolumeVOI_js__rspack_import_7 = __webpack_require__(26365);
46117
+ /* import */ var _init_js__rspack_import_8 = __webpack_require__(90934);
46118
+
46119
+
46013
46120
 
46014
46121
 
46015
46122
 
@@ -46023,23 +46130,35 @@ async function createVolumeActor(props, element, viewportId, suppressEvents = fa
46023
46130
  if (!imageVolume) {
46024
46131
  throw new Error(`imageVolume with id: ${imageVolume.volumeId} does not exist`);
46025
46132
  }
46026
- const { imageData, vtkOpenGLTexture } = imageVolume;
46027
- const volumeMapper = (0,_createVolumeMapper_js__rspack_import_2/* ["default"] */.A)(imageData, vtkOpenGLTexture);
46133
+ const { imageData } = imageVolume;
46134
+ const { strategy, texture: vtkOpenGLTexture } = (0,_resolveVolumeTexture_js__rspack_import_3/* .resolveVolumeTexture */.M)(imageVolume, {
46135
+ provideStrategies: props.provideStrategies,
46136
+ selectStrategy: props.selectStrategy,
46137
+ viewportId,
46138
+ });
46139
+ const usesRenderPath = props.provideStrategies !== undefined || props.selectStrategy !== undefined;
46140
+ if (!vtkOpenGLTexture && !usesRenderPath) {
46141
+ throw new Error(`no render strategy gives a texture for the volume ${volumeId}`);
46142
+ }
46143
+ const volumeMapper = (0,_createVolumeMapper_js__rspack_import_2/* ["default"] */.Ay)(imageData, vtkOpenGLTexture);
46028
46144
  if (blendMode) {
46029
46145
  volumeMapper.setBlendMode(blendMode);
46030
46146
  }
46031
46147
  const volumeActor = _kitware_vtk_js_Rendering_Core_Volume_js__rspack_import_0/* ["default"].newInstance */.Ay.newInstance();
46032
46148
  volumeActor.setMapper(volumeMapper);
46149
+ if (!usesRenderPath) {
46150
+ (0,_legacyActorTextureSet_js__rspack_import_4/* .claimLegacyActorTextureSet */.G)(volumeActor, imageVolume, strategy.name);
46151
+ }
46033
46152
  const { numberOfComponents } = imageData.get('numberOfComponents');
46034
46153
  const volumeProperty = volumeActor.getProperty();
46035
46154
  volumeProperty.set({ viewportId: viewportId }, true);
46036
- if ((0,_init_js__rspack_import_6/* .getConfiguration */.D0)().rendering.preferSizeOverAccuracy) {
46155
+ if ((0,_init_js__rspack_import_8/* .getConfiguration */.D0)().rendering.preferSizeOverAccuracy) {
46037
46156
  volumeProperty.setPreferSizeOverAccuracy(true);
46038
46157
  }
46039
46158
  if (numberOfComponents === 3) {
46040
46159
  volumeActor.getProperty().setIndependentComponents(false);
46041
46160
  }
46042
- await (0,_setDefaultVolumeVOI_js__rspack_import_5/* ["default"] */.A)(volumeActor, imageVolume);
46161
+ await (0,_setDefaultVolumeVOI_js__rspack_import_7/* ["default"] */.A)(volumeActor, imageVolume);
46043
46162
  if (callback) {
46044
46163
  callback({ volumeActor, volumeId });
46045
46164
  }
@@ -46061,7 +46180,7 @@ function triggerVOIModified(element, viewportId, volumeActor, volumeId) {
46061
46180
  },
46062
46181
  volumeId,
46063
46182
  };
46064
- (0,_utilities_triggerEvent_js__rspack_import_3/* ["default"] */.A)(element, _enums_index_js__rspack_import_4.Events.VOI_MODIFIED, voiModifiedEventDetail);
46183
+ (0,_utilities_triggerEvent_js__rspack_import_5/* ["default"] */.A)(element, _enums_index_js__rspack_import_6.Events.VOI_MODIFIED, voiModifiedEventDetail);
46065
46184
  }
46066
46185
  /* export default */ __webpack_exports__.A = (createVolumeActor);
46067
46186
 
@@ -46108,6 +46227,814 @@ __webpack_require__.d(__webpack_exports__, {
46108
46227
  });
46109
46228
 
46110
46229
 
46230
+ },
46231
+ 22617(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
46232
+ "use strict";
46233
+ /* import */ var _enums_ImageQualityStatus_js__rspack_import_0 = __webpack_require__(7330);
46234
+ /* import */ var _utilities_voxelGrid_index_js__rspack_import_1 = __webpack_require__(49617);
46235
+ /* import */ var _fidelityIndicatorState_js__rspack_import_2 = __webpack_require__(56196);
46236
+ /* import */ var _fidelityLabel_js__rspack_import_3 = __webpack_require__(21130);
46237
+
46238
+
46239
+
46240
+
46241
+ function buildViewportFidelityState(lines, displaySpacing) {
46242
+ const line = worstLineOf(lines);
46243
+ if (!line) {
46244
+ return emptyState(displaySpacing);
46245
+ }
46246
+ const shownState = (0,_fidelityIndicatorState_js__rspack_import_2/* .shownStateOf */.m9)(lines);
46247
+ const { record, reductionFactors, imageQualityStatus } = line;
46248
+ const shownSpacing = line.displaySpacing ?? displaySpacing;
46249
+ const spatiallyReduced = (0,_fidelityIndicatorState_js__rspack_import_2/* .isReduced */.H3)(reductionFactors);
46250
+ const kind = (0,_fidelityIndicatorState_js__rspack_import_2/* .lineKind */.nN)(line);
46251
+ const loading = kind === 'loading';
46252
+ const lod = kind === 'lod';
46253
+ const lossy = (0,_fidelityLabel_js__rspack_import_3/* .fidelityLabelOf */.C)(shownState) !== null;
46254
+ const state = {
46255
+ dataResolution: record
46256
+ ? {
46257
+ spacing: [...record.grid.spacing],
46258
+ dimensions: [...record.grid.dimensions],
46259
+ }
46260
+ : undefined,
46261
+ displayResolution: shownSpacing
46262
+ ? { spacing: [...shownSpacing] }
46263
+ : undefined,
46264
+ reductionKind: record?.reduction,
46265
+ reductionSource: record?.source,
46266
+ magnitude: lossy ? [...reductionFactors] : undefined,
46267
+ cause: lossy
46268
+ ? causeOf({
46269
+ record,
46270
+ imageQualityStatus,
46271
+ reductionCause: line.reductionCause,
46272
+ spatiallyReduced,
46273
+ standingSample: (0,_fidelityIndicatorState_js__rspack_import_2/* .isInteractiveLod */.kq)((0,_fidelityIndicatorState_js__rspack_import_2/* .standingSampleRatioOf */.ZX)(line)),
46274
+ loading,
46275
+ lod,
46276
+ missingFrames: !line.qualityPending && record?.missing > 0,
46277
+ })
46278
+ : undefined,
46279
+ transient: lossy ? loading || lod : undefined,
46280
+ progressive: progressiveOf(line),
46281
+ shownState,
46282
+ lossy,
46283
+ };
46284
+ return state;
46285
+ }
46286
+ function emptyState(displaySpacing) {
46287
+ return {
46288
+ dataResolution: undefined,
46289
+ displayResolution: displaySpacing
46290
+ ? { spacing: [...displaySpacing] }
46291
+ : undefined,
46292
+ reductionKind: undefined,
46293
+ reductionSource: undefined,
46294
+ magnitude: undefined,
46295
+ cause: undefined,
46296
+ transient: undefined,
46297
+ progressive: undefined,
46298
+ shownState: 'hidden',
46299
+ lossy: false,
46300
+ };
46301
+ }
46302
+ function worstLineOf(lines) {
46303
+ let worst;
46304
+ let worstRank = 0;
46305
+ for (const line of lines) {
46306
+ if (!(0,_fidelityIndicatorState_js__rspack_import_2/* .lineHasData */.lM)(line)) {
46307
+ continue;
46308
+ }
46309
+ const rank = (0,_fidelityIndicatorState_js__rspack_import_2/* .fidelityStateRank */.cM)((0,_fidelityIndicatorState_js__rspack_import_2/* .lineKind */.nN)(line));
46310
+ if (rank > worstRank ||
46311
+ (rank === worstRank && !worst.record && line.record)) {
46312
+ worst = line;
46313
+ worstRank = rank;
46314
+ }
46315
+ }
46316
+ return worst;
46317
+ }
46318
+ function progressiveOf(line) {
46319
+ const { record, imageQualityStatus } = line;
46320
+ if (record) {
46321
+ const loadedFraction = record.voxels > 0
46322
+ ? (record.voxels - record.missing) / record.voxels
46323
+ : undefined;
46324
+ return {
46325
+ status: record.status,
46326
+ lowest: record.lowest,
46327
+ missing: record.missing,
46328
+ voxels: record.voxels,
46329
+ loadedFraction,
46330
+ };
46331
+ }
46332
+ if (imageQualityStatus !== undefined) {
46333
+ return {
46334
+ status: imageQualityStatus,
46335
+ };
46336
+ }
46337
+ return undefined;
46338
+ }
46339
+ function causeOf(args) {
46340
+ const { record, imageQualityStatus, reductionCause, spatiallyReduced, standingSample, loading, lod, missingFrames, } = args;
46341
+ if (loading) {
46342
+ return 'incompleteLoad';
46343
+ }
46344
+ if (lod) {
46345
+ return 'performanceTarget';
46346
+ }
46347
+ const spatial = spatiallyReduced || (record && (0,_utilities_voxelGrid_index_js__rspack_import_1.isAliasingReduction)(record.reduction));
46348
+ if (spatial && reductionCause) {
46349
+ return reductionCause;
46350
+ }
46351
+ if (missingFrames) {
46352
+ return 'missingFrames';
46353
+ }
46354
+ const delivered = record ? record.lowest : imageQualityStatus;
46355
+ if (delivered !== undefined &&
46356
+ delivered < _enums_ImageQualityStatus_js__rspack_import_0/* ["default"].FULL_RESOLUTION */.A.FULL_RESOLUTION &&
46357
+ delivered >= _enums_ImageQualityStatus_js__rspack_import_0/* ["default"].SUBRESOLUTION */.A.SUBRESOLUTION) {
46358
+ return 'lossyDecode';
46359
+ }
46360
+ return standingSample && !spatial ? 'performanceTarget' : undefined;
46361
+ }
46362
+ function viewportFidelityStateKey(state) {
46363
+ return JSON.stringify({
46364
+ shownState: state.shownState,
46365
+ lossy: state.lossy,
46366
+ dataResolution: state.dataResolution,
46367
+ reductionKind: state.reductionKind,
46368
+ reductionSource: state.reductionSource,
46369
+ magnitude: state.magnitude,
46370
+ cause: state.cause,
46371
+ transient: state.transient,
46372
+ progressive: state.lossy ? state.progressive : undefined,
46373
+ });
46374
+ }
46375
+
46376
+ __webpack_require__.d(__webpack_exports__, {
46377
+ B: () => (viewportFidelityStateKey),
46378
+ m: () => (buildViewportFidelityState)
46379
+ });
46380
+
46381
+
46382
+ },
46383
+ 91339(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
46384
+ "use strict";
46385
+ /* import */ var _cache_cache_js__rspack_import_0 = __webpack_require__(73998);
46386
+ /* import */ var _enums_ImageQualityStatus_js__rspack_import_1 = __webpack_require__(7330);
46387
+ /* import */ var _enums_ViewportType_js__rspack_import_2 = __webpack_require__(32168);
46388
+ /* import */ var _utilities_voxelGrid_index_js__rspack_import_3 = __webpack_require__(49617);
46389
+ /* import */ var _createVolumeMapper_js__rspack_import_4 = __webpack_require__(9891);
46390
+ /* import */ var _volumeRenderStrategy_js__rspack_import_5 = __webpack_require__(53703);
46391
+ /* import */ var _GenericViewport_renderingFidelity_js__rspack_import_6 = __webpack_require__(67746);
46392
+ /* import */ var _utilities_gpuSettingsPresets_js__rspack_import_7 = __webpack_require__(701);
46393
+ /* import */ var _displaySpacingOfViewport_js__rspack_import_8 = __webpack_require__(42704);
46394
+ /* import */ var _isLabelmapActorEntry_js__rspack_import_9 = __webpack_require__(12915);
46395
+ /* import */ var _fidelityIndicatorState_js__rspack_import_10 = __webpack_require__(56196);
46396
+
46397
+
46398
+
46399
+
46400
+
46401
+
46402
+
46403
+
46404
+
46405
+
46406
+
46407
+ function fidelityLinesFromBindings(display, sources) {
46408
+ const lines = [];
46409
+ for (const source of sources) {
46410
+ if (source.skip) {
46411
+ continue;
46412
+ }
46413
+ if (!source.record) {
46414
+ if (source.imageQualityStatus !== undefined) {
46415
+ lines.push({
46416
+ ...fidelityLineFromImageQuality(source.imageQualityStatus, source.qualityPending),
46417
+ label: source.label ?? 'Image',
46418
+ interactiveReduction: source.interactiveReduction,
46419
+ });
46420
+ }
46421
+ continue;
46422
+ }
46423
+ const { record } = source;
46424
+ const fullGrid = source.fullGrid ?? record.grid;
46425
+ const reductionFactors = (0,_fidelityIndicatorState_js__rspack_import_10/* .reductionFactorsOf */.JH)(record.grid, fullGrid);
46426
+ const fullResolution = !(0,_fidelityIndicatorState_js__rspack_import_10/* .isReduced */.H3)(reductionFactors);
46427
+ const displaySpacing = display
46428
+ ? (0,_displaySpacingOfViewport_js__rspack_import_8/* .displaySpacingForGrid */.lC)(display, record.grid, fullGrid)
46429
+ : undefined;
46430
+ const verdict = displaySpacing
46431
+ ? (0,_utilities_voxelGrid_index_js__rspack_import_3.compareVoxelQuality)(record, { displaySpacing })
46432
+ : undefined;
46433
+ lines.push({
46434
+ label: source.label ?? 'Image',
46435
+ record,
46436
+ verdict,
46437
+ displaySpacing,
46438
+ reductionFactors,
46439
+ fullResolution,
46440
+ sampleDistanceLod: source.sampleDistanceLod ?? 1,
46441
+ sampleDistanceIdle: source.sampleDistanceIdle,
46442
+ interactiveReduction: source.interactiveReduction,
46443
+ qualityPending: source.qualityPending,
46444
+ reductionCause: source.reductionCause,
46445
+ });
46446
+ }
46447
+ return lines;
46448
+ }
46449
+ function fidelityLinesFromVolumeActors(viewport, records = new Map()) {
46450
+ const actors = viewport.getActors();
46451
+ if (!actors.length) {
46452
+ return [];
46453
+ }
46454
+ const volume3D = isVolume3D(viewport);
46455
+ const display = (0,_displaySpacingOfViewport_js__rspack_import_8/* .fidelityDisplayOfCamera */.N)(viewport, volume3D);
46456
+ const lines = [];
46457
+ const seen = new Set();
46458
+ for (const entry of actors) {
46459
+ const id = entry.referencedId ?? entry.uid;
46460
+ const volume = id ? _cache_cache_js__rspack_import_0/* ["default"].getVolume */.Ay.getVolume(id) : undefined;
46461
+ if (!volume || seen.has(id) || (0,_isLabelmapActorEntry_js__rspack_import_9/* .isLabelmapActorEntry */.O)(entry)) {
46462
+ continue;
46463
+ }
46464
+ seen.add(id);
46465
+ const mapper = entry.actor.getMapper?.();
46466
+ const texture = mapper?.getScalarTexture?.();
46467
+ const grid = texture?.getGrid?.() ?? volume.voxelGrid;
46468
+ const fullGrid = volume.voxelGrid;
46469
+ let cached = records.get(id);
46470
+ if (!cached || !(0,_utilities_voxelGrid_index_js__rspack_import_3.voxelGridsEqual)(cached.grid, grid)) {
46471
+ const statistic = texture?.getStatistic?.() ?? volume.reductionStatistic;
46472
+ cached = {
46473
+ grid,
46474
+ record: volume.getGridQuality(grid, statistic),
46475
+ };
46476
+ records.set(id, cached);
46477
+ }
46478
+ const reductionFactors = (0,_fidelityIndicatorState_js__rspack_import_10/* .reductionFactorsOf */.JH)(grid, fullGrid);
46479
+ const fullResolution = !(0,_fidelityIndicatorState_js__rspack_import_10/* .isReduced */.H3)(reductionFactors);
46480
+ const record = cached.record;
46481
+ const sampleDistance = volume3D
46482
+ ? (0,_createVolumeMapper_js__rspack_import_4/* .sampleDistanceRatiosOf */.nr)(mapper)
46483
+ : { current: 1, idle: 1 };
46484
+ const displaySpacing = display
46485
+ ? (0,_displaySpacingOfViewport_js__rspack_import_8/* .displaySpacingForGrid */.lC)(display, grid, fullGrid)
46486
+ : undefined;
46487
+ const verdict = record && displaySpacing
46488
+ ? (0,_utilities_voxelGrid_index_js__rspack_import_3.compareVoxelQuality)(record, { displaySpacing })
46489
+ : undefined;
46490
+ lines.push({
46491
+ label: 'Image',
46492
+ record: record ?? undefined,
46493
+ verdict,
46494
+ displaySpacing,
46495
+ reductionFactors,
46496
+ fullResolution,
46497
+ sampleDistanceLod: sampleDistance.current,
46498
+ sampleDistanceIdle: sampleDistance.idle,
46499
+ qualityPending: (0,_GenericViewport_renderingFidelity_js__rspack_import_6/* .isBindingPending */.l_)(volume, texture),
46500
+ reductionCause: fullResolution
46501
+ ? undefined
46502
+ : (0,_volumeRenderStrategy_js__rspack_import_5/* .reductionCauseOf */.wH)(volume, (0,_utilities_gpuSettingsPresets_js__rspack_import_7/* .gpuSettingsForRender */.je)()),
46503
+ });
46504
+ }
46505
+ return lines;
46506
+ }
46507
+ function isVolume3D(viewport) {
46508
+ return (viewport.type === _enums_ViewportType_js__rspack_import_2/* ["default"].VOLUME_3D */.A.VOLUME_3D ||
46509
+ viewport.type === _enums_ViewportType_js__rspack_import_2/* ["default"].PERSPECTIVE */.A.PERSPECTIVE);
46510
+ }
46511
+ function fidelityLineFromImageQuality(imageQualityStatus, qualityPending) {
46512
+ return {
46513
+ label: 'Image',
46514
+ imageQualityStatus,
46515
+ qualityPending,
46516
+ reductionFactors: [1, 1, 1],
46517
+ fullResolution: imageQualityStatus === _enums_ImageQualityStatus_js__rspack_import_1/* ["default"].FULL_RESOLUTION */.A.FULL_RESOLUTION,
46518
+ sampleDistanceLod: 1,
46519
+ };
46520
+ }
46521
+ function fidelityLineFromStackImage(image) {
46522
+ if (!image) {
46523
+ return [];
46524
+ }
46525
+ return [
46526
+ fidelityLineFromImageQuality(imageQualityStatusOf(image), image.imageQualityPending),
46527
+ ];
46528
+ }
46529
+ function imageQualityStatusOf(image) {
46530
+ return image
46531
+ ? (image.imageQualityStatus ?? _enums_ImageQualityStatus_js__rspack_import_1/* ["default"].FULL_RESOLUTION */.A.FULL_RESOLUTION)
46532
+ : undefined;
46533
+ }
46534
+
46535
+ __webpack_require__.d(__webpack_exports__, {
46536
+ Gs: () => (imageQualityStatusOf),
46537
+ a0: () => (fidelityLineFromStackImage),
46538
+ e0: () => (fidelityLinesFromBindings),
46539
+ yb: () => (fidelityLinesFromVolumeActors)
46540
+ });
46541
+
46542
+
46543
+ },
46544
+ 42704(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
46545
+ "use strict";
46546
+ /* import */ var _enums_BlendModes_js__rspack_import_0 = __webpack_require__(21319);
46547
+ /* import */ var _utilities_getSpacingInNormalDirection_js__rspack_import_1 = __webpack_require__(1680);
46548
+
46549
+
46550
+ function averageSlabThicknessOf(viewport) {
46551
+ return viewport.getBlendMode?.() === _enums_BlendModes_js__rspack_import_0/* ["default"].AVERAGE_INTENSITY_BLEND */.A.AVERAGE_INTENSITY_BLEND
46552
+ ? viewport.getSlabThickness?.()
46553
+ : undefined;
46554
+ }
46555
+ function fidelityDisplayOfCamera(viewport, volume3D = false) {
46556
+ const camera = viewport.getCamera?.();
46557
+ const parallelScale = camera?.parallelScale;
46558
+ const height = viewport.canvas?.height ||
46559
+ viewport.canvas?.clientHeight ||
46560
+ viewport.sHeight;
46561
+ if (!(parallelScale > 0) ||
46562
+ !(height > 0) ||
46563
+ camera.parallelProjection === false) {
46564
+ return undefined;
46565
+ }
46566
+ return {
46567
+ pixelSpacing: (2 * parallelScale) / height,
46568
+ viewPlaneNormal: camera.viewPlaneNormal,
46569
+ volume3D,
46570
+ averageSlabThickness: averageSlabThicknessOf(viewport),
46571
+ };
46572
+ }
46573
+ function pixelSpacingOfCanvasToWorld(canvasToWorld) {
46574
+ const a = canvasToWorld([0, 0]);
46575
+ const b = canvasToWorld([1, 0]);
46576
+ const cssPixel = Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);
46577
+ const ratio = (typeof window !== 'undefined' && window.devicePixelRatio) || 1;
46578
+ return cssPixel > 0 && Number.isFinite(cssPixel)
46579
+ ? cssPixel / ratio
46580
+ : undefined;
46581
+ }
46582
+ function displaySpacingForGrid(display, grid, sourceGrid = grid) {
46583
+ const { pixelSpacing: pixel, viewPlaneNormal: normal, volume3D } = display;
46584
+ const slice = !volume3D && normal
46585
+ ? Math.max((0,_utilities_getSpacingInNormalDirection_js__rspack_import_1/* ["default"] */.A)(sourceGrid, normal), display.averageSlabThickness || 0)
46586
+ : 0;
46587
+ const spacing = [pixel, pixel, pixel];
46588
+ for (let axis = 0; axis < 3; axis++) {
46589
+ if (slice > 0) {
46590
+ const offset = axis * 3;
46591
+ const c = Math.min(1, Math.abs(grid.direction[offset] * normal[0] +
46592
+ grid.direction[offset + 1] * normal[1] +
46593
+ grid.direction[offset + 2] * normal[2]));
46594
+ const inPlane = c < 1 - 1e-9 ? pixel / Math.sqrt(1 - c * c) : Number.POSITIVE_INFINITY;
46595
+ const alongNormal = c > 1e-9 ? slice / c : Number.POSITIVE_INFINITY;
46596
+ const blended = Math.min(inPlane, alongNormal);
46597
+ spacing[axis] = Number.isFinite(blended) ? blended : pixel;
46598
+ }
46599
+ spacing[axis] = Math.max(spacing[axis], sourceGrid.spacing[axis] || 0);
46600
+ }
46601
+ return spacing;
46602
+ }
46603
+ function displaySpacingOfDisplay(display) {
46604
+ return display
46605
+ ? [display.pixelSpacing, display.pixelSpacing, display.pixelSpacing]
46606
+ : undefined;
46607
+ }
46608
+ function displaySpacingOfViewport(viewport, options = {}) {
46609
+ const display = fidelityDisplayOfCamera(viewport, options.volume3D);
46610
+ if (!display || !options.grid) {
46611
+ return displaySpacingOfDisplay(display);
46612
+ }
46613
+ return displaySpacingForGrid(display, options.grid, options.sourceGrid);
46614
+ }
46615
+
46616
+ __webpack_require__.d(__webpack_exports__, {
46617
+ KC: () => (pixelSpacingOfCanvasToWorld),
46618
+ N: () => (fidelityDisplayOfCamera),
46619
+ Tu: () => (displaySpacingOfDisplay),
46620
+ dA: () => (displaySpacingOfViewport),
46621
+ dH: () => (averageSlabThicknessOf),
46622
+ lC: () => (displaySpacingForGrid)
46623
+ });
46624
+
46625
+
46626
+ },
46627
+ 65429(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
46628
+ "use strict";
46629
+ /* import */ var _fidelityIndicatorState_js__rspack_import_0 = __webpack_require__(56196);
46630
+
46631
+ function fidelityDetailsTextOf(state, lines) {
46632
+ if (!state.cause && !state.magnitude && !state.progressive) {
46633
+ if (state.shownState === 'done' || state.lossy === false) {
46634
+ return 'Image is at full available detail.';
46635
+ }
46636
+ return 'No image data in this viewport yet';
46637
+ }
46638
+ if (state.shownState === 'done' || state.lossy === false) {
46639
+ return 'Image is at full available detail.';
46640
+ }
46641
+ const parts = [];
46642
+ const multi = lines && lines.length > 1
46643
+ ? lines.map((line) => line.label).filter(Boolean)
46644
+ : [];
46645
+ if (multi.length > 1) {
46646
+ parts.push(multi.join(', '));
46647
+ }
46648
+ switch (state.cause) {
46649
+ case 'incompleteLoad':
46650
+ parts.push('Image is still loading.');
46651
+ parts.push(...progressLines(state));
46652
+ parts.push('Waiting should improve the image.');
46653
+ break;
46654
+ case 'missingFrames':
46655
+ parts.push('Missing frame(s)');
46656
+ parts.push(...progressLines(state));
46657
+ parts.push('Waiting will not improve the image.');
46658
+ break;
46659
+ case 'performanceTarget':
46660
+ if (state.transient) {
46661
+ parts.push('Detail is reduced while you interact.');
46662
+ parts.push(...magnitudeLines(state.magnitude));
46663
+ parts.push('Full detail returns when interaction stops.');
46664
+ }
46665
+ else {
46666
+ parts.push('Detail is reduced to keep the display fast.');
46667
+ parts.push('Waiting will not improve the image.');
46668
+ }
46669
+ break;
46670
+ case 'lossyDecode':
46671
+ parts.push('Image uses reduced decode quality.');
46672
+ parts.push(...magnitudeLines(state.magnitude));
46673
+ parts.push(...waitLine(state.transient));
46674
+ break;
46675
+ case 'deviceTextureLimit':
46676
+ parts.push('Image detail is reduced to fit the limits of this device.');
46677
+ parts.push(...magnitudeLines(state.magnitude));
46678
+ parts.push('Waiting will not improve the image.');
46679
+ break;
46680
+ case 'memoryBudget':
46681
+ parts.push('Image detail is reduced to fit the available memory.');
46682
+ parts.push(...magnitudeLines(state.magnitude));
46683
+ parts.push('Waiting will not improve the image.');
46684
+ break;
46685
+ default:
46686
+ if (state.transient) {
46687
+ parts.push('Image detail is temporarily reduced.');
46688
+ parts.push(...progressLines(state));
46689
+ parts.push(...magnitudeLines(state.magnitude));
46690
+ parts.push('Waiting should improve the image.');
46691
+ }
46692
+ else if (state.magnitude && (0,_fidelityIndicatorState_js__rspack_import_0/* .isReduced */.H3)(state.magnitude)) {
46693
+ parts.push('Image detail is reduced.');
46694
+ parts.push(...magnitudeLines(state.magnitude));
46695
+ }
46696
+ else if (state.progressive) {
46697
+ parts.push(...progressLines(state));
46698
+ }
46699
+ else {
46700
+ parts.push('Image is at full available detail.');
46701
+ }
46702
+ break;
46703
+ }
46704
+ if (!state.transient &&
46705
+ lines?.some((line) => (0,_fidelityIndicatorState_js__rspack_import_0/* .lineHasData */.lM)(line) && (0,_fidelityIndicatorState_js__rspack_import_0/* .lineKind */.nN)(line) === 'loading')) {
46706
+ parts.push('Other data is still loading.');
46707
+ }
46708
+ return parts.filter(Boolean).join('\n');
46709
+ }
46710
+ function progressLines(state) {
46711
+ const fraction = state.progressive?.loadedFraction;
46712
+ if (fraction === undefined || !(fraction >= 0)) {
46713
+ return [];
46714
+ }
46715
+ const percent = Math.min(99, Math.floor(100 * fraction));
46716
+ return [`${percent}% of data arrived.`];
46717
+ }
46718
+ function magnitudeLines(magnitude) {
46719
+ if (!magnitude || !(0,_fidelityIndicatorState_js__rspack_import_0/* .isReduced */.H3)(magnitude)) {
46720
+ return [];
46721
+ }
46722
+ return [
46723
+ `Reduction: x/${formatAxis(magnitude[0])}, y/${formatAxis(magnitude[1])}, z/${formatAxis(magnitude[2])}`,
46724
+ ];
46725
+ }
46726
+ function waitLine(transient) {
46727
+ if (transient) {
46728
+ return ['Waiting should improve the image.'];
46729
+ }
46730
+ return [];
46731
+ }
46732
+ function formatAxis(value) {
46733
+ if (!Number.isFinite(value) || value <= 0) {
46734
+ return '1';
46735
+ }
46736
+ return (0,_fidelityIndicatorState_js__rspack_import_0/* .formatReductionFactor */.Yn)(value);
46737
+ }
46738
+
46739
+ __webpack_require__.d(__webpack_exports__, {
46740
+ X: () => (fidelityDetailsTextOf)
46741
+ });
46742
+
46743
+
46744
+ },
46745
+ 56196(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
46746
+ "use strict";
46747
+ /* import */ var _enums_ImageQualityStatus_js__rspack_import_0 = __webpack_require__(7330);
46748
+ /* import */ var _utilities_voxelGrid_index_js__rspack_import_1 = __webpack_require__(49617);
46749
+
46750
+
46751
+ function lineHasData(line) {
46752
+ if (line.record) {
46753
+ return line.record.lowest !== undefined;
46754
+ }
46755
+ return line.imageQualityStatus !== undefined || !line.fullResolution;
46756
+ }
46757
+ const FIDELITY_STATE_ORDER = [
46758
+ 'lossy',
46759
+ 'loading',
46760
+ 'lod',
46761
+ 'done',
46762
+ ];
46763
+ function fidelityStateRank(state) {
46764
+ return FIDELITY_STATE_ORDER.length - FIDELITY_STATE_ORDER.indexOf(state);
46765
+ }
46766
+ function shownStateOf(lines) {
46767
+ let worst = 'hidden';
46768
+ let worstRank = 0;
46769
+ for (const line of lines) {
46770
+ if (!lineHasData(line)) {
46771
+ continue;
46772
+ }
46773
+ const kind = lineKind(line);
46774
+ const rank = fidelityStateRank(kind);
46775
+ if (rank > worstRank) {
46776
+ worst = kind;
46777
+ worstRank = rank;
46778
+ }
46779
+ }
46780
+ return worst;
46781
+ }
46782
+ function dataKindOf(line) {
46783
+ const { record, imageQualityStatus, qualityPending } = line;
46784
+ if (!record) {
46785
+ return imageQualityStatus !== undefined
46786
+ ? dataKindOfImageQuality(imageQualityStatus, qualityPending)
46787
+ : 'reduced';
46788
+ }
46789
+ const spatialKind = spatialKindOf(line);
46790
+ if (spatialKind !== 'full') {
46791
+ return spatialKind;
46792
+ }
46793
+ const lowest = record.lowest ?? _enums_ImageQualityStatus_js__rspack_import_0/* ["default"].FULL_RESOLUTION */.A.FULL_RESOLUTION;
46794
+ const lossyDelivery = lowest < _enums_ImageQualityStatus_js__rspack_import_0/* ["default"].FULL_RESOLUTION */.A.FULL_RESOLUTION;
46795
+ if (qualityPending) {
46796
+ if (lossyDelivery || record.missing === 0) {
46797
+ return 'loading';
46798
+ }
46799
+ }
46800
+ else if (record.missing > 0) {
46801
+ return 'reduced';
46802
+ }
46803
+ if (lossyDelivery || isInteractiveLod(standingSampleRatioOf(line))) {
46804
+ return 'reduced';
46805
+ }
46806
+ return 'full';
46807
+ }
46808
+ function spatialKindOf(line) {
46809
+ const { record, reductionFactors, fullResolution, verdict } = line;
46810
+ if ((0,_utilities_voxelGrid_index_js__rspack_import_1.isAliasingReduction)(record.reduction)) {
46811
+ return 'decimated';
46812
+ }
46813
+ if (fullResolution && !isReduced(reductionFactors)) {
46814
+ return 'full';
46815
+ }
46816
+ if (!verdict) {
46817
+ return 'reduced';
46818
+ }
46819
+ if (verdict.causes.includes('aliasing')) {
46820
+ return 'decimated';
46821
+ }
46822
+ return verdict.causes.includes('resolution') ? 'reduced' : 'full';
46823
+ }
46824
+ function standingSampleRatioOf(line) {
46825
+ return line.sampleDistanceIdle ?? line.sampleDistanceLod;
46826
+ }
46827
+ function interactiveSampleRatioOf(line) {
46828
+ return line.sampleDistanceLod / (standingSampleRatioOf(line) || 1);
46829
+ }
46830
+ function dataKindOfImageQuality(status, pending = false) {
46831
+ if (status >= _enums_ImageQualityStatus_js__rspack_import_0/* ["default"].FULL_RESOLUTION */.A.FULL_RESOLUTION) {
46832
+ return 'full';
46833
+ }
46834
+ if (status >= _enums_ImageQualityStatus_js__rspack_import_0/* ["default"].SUBRESOLUTION */.A.SUBRESOLUTION) {
46835
+ return pending ? 'loading' : 'reduced';
46836
+ }
46837
+ return 'loading';
46838
+ }
46839
+ function lineKind(line) {
46840
+ const dataKind = dataKindOf(line);
46841
+ if (dataKind === 'loading') {
46842
+ return 'loading';
46843
+ }
46844
+ if (dataKind !== 'full') {
46845
+ return 'lossy';
46846
+ }
46847
+ return isInteractiveLine(line) ? 'lod' : 'done';
46848
+ }
46849
+ function isInteractiveLine(line) {
46850
+ return (isInteractiveLod(interactiveSampleRatioOf(line)) ||
46851
+ !!line.interactiveReduction);
46852
+ }
46853
+ function reductionFactorsOf(drawn, full) {
46854
+ const factors = [1, 1, 1];
46855
+ for (let axis = 0; axis < 3; axis++) {
46856
+ const fullSpacing = full.spacing[axis];
46857
+ if (!(fullSpacing > 0)) {
46858
+ continue;
46859
+ }
46860
+ factors[axis] = drawn.spacing[axis] / fullSpacing;
46861
+ }
46862
+ return factors;
46863
+ }
46864
+ function isReduced(factors) {
46865
+ return factors.some((factor) => factor > 1 + 1e-6);
46866
+ }
46867
+ function formatFactors(factors) {
46868
+ return factors.map(formatReductionFactor).join('×');
46869
+ }
46870
+ function formatReductionFactor(value) {
46871
+ const text = formatFactor(value, 2);
46872
+ return text === '1.00' && value > 1 ? '<1.01' : text;
46873
+ }
46874
+ function isInteractiveLod(sampleDistanceLod) {
46875
+ return sampleDistanceLod > 1 + 1e-2;
46876
+ }
46877
+ function formatFactor(value, digits = 1) {
46878
+ const rounded = Math.round(value);
46879
+ if (Math.abs(value - rounded) < 1e-6) {
46880
+ return String(rounded);
46881
+ }
46882
+ return value.toFixed(digits);
46883
+ }
46884
+
46885
+ __webpack_require__.d(__webpack_exports__, {
46886
+ H3: () => (isReduced),
46887
+ H9: () => (formatFactor),
46888
+ JH: () => (reductionFactorsOf),
46889
+ Sb: () => (dataKindOf),
46890
+ Yn: () => (formatReductionFactor),
46891
+ ZX: () => (standingSampleRatioOf),
46892
+ cM: () => (fidelityStateRank),
46893
+ kq: () => (isInteractiveLod),
46894
+ lM: () => (lineHasData),
46895
+ m9: () => (shownStateOf),
46896
+ nN: () => (lineKind),
46897
+ te: () => (interactiveSampleRatioOf),
46898
+ uB: () => (formatFactors)
46899
+ });
46900
+
46901
+
46902
+ },
46903
+ 8699(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
46904
+ "use strict";
46905
+ const FIDELITY_INDICATOR_CSS = `/*
46906
+ * Text-only product indicator in the top-right. .fi-root has data-state
46907
+ * (loading | lod | lossy) only while the label shows.
46908
+ */
46909
+
46910
+ .fi-root {
46911
+ display: flex;
46912
+ flex-direction: row;
46913
+ align-items: center;
46914
+ pointer-events: auto;
46915
+ }
46916
+
46917
+ /* No label: not hoverable (avoids a floating tooltip). */
46918
+ .fi-root:not([data-state]) {
46919
+ pointer-events: none;
46920
+ }
46921
+
46922
+ /* Permanent clinician label (FIDELITY-UI-2): bright red on black. */
46923
+ .fi-label {
46924
+ display: none;
46925
+ flex-shrink: 0;
46926
+ padding: 4px 8px;
46927
+ font: 600 12px/1.2 system-ui, sans-serif;
46928
+ color: #ff2020;
46929
+ background: #000;
46930
+ white-space: nowrap;
46931
+ pointer-events: none;
46932
+ }
46933
+
46934
+ .fi-root[data-state] .fi-label {
46935
+ display: block;
46936
+ }
46937
+
46938
+ /* Product fidelity tooltip (label hover). Clinician copy (FIDELITY-UI-5). */
46939
+ .fi-details {
46940
+ display: none;
46941
+ position: absolute;
46942
+ top: 100%;
46943
+ right: 0;
46944
+ margin: 4px 0 0;
46945
+ padding: 6px 8px;
46946
+ background: rgba(0, 0, 0, 0.85);
46947
+ border-radius: 4px;
46948
+ color: #fff;
46949
+ font: 12px/1.35 system-ui, sans-serif;
46950
+ text-align: left;
46951
+ white-space: pre-wrap;
46952
+ pointer-events: none;
46953
+ z-index: 1;
46954
+ max-width: 240px;
46955
+ }
46956
+
46957
+ .fi-root[data-hover='true'] .fi-details {
46958
+ display: block;
46959
+ }
46960
+ `;
46961
+ let injected = false;
46962
+ function ensureFidelityIndicatorStyles() {
46963
+ if (injected || typeof document === 'undefined') {
46964
+ return;
46965
+ }
46966
+ injected = true;
46967
+ const style = document.createElement('style');
46968
+ style.setAttribute('data-fidelity-indicator', '');
46969
+ style.textContent = FIDELITY_INDICATOR_CSS;
46970
+ document.head.appendChild(style);
46971
+ }
46972
+
46973
+ __webpack_require__.d(__webpack_exports__, {
46974
+ C: () => (ensureFidelityIndicatorStyles)
46975
+ });
46976
+
46977
+
46978
+ },
46979
+ 21130(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
46980
+ "use strict";
46981
+ function fidelityLabelOf(state) {
46982
+ if (state === 'hidden' || state === 'done') {
46983
+ return null;
46984
+ }
46985
+ return state === 'lossy' ? 'Low Fidelity' : 'Transient Low Fidelity';
46986
+ }
46987
+
46988
+ __webpack_require__.d(__webpack_exports__, {
46989
+ C: () => (fidelityLabelOf)
46990
+ });
46991
+
46992
+
46993
+ },
46994
+ 12915(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
46995
+ "use strict";
46996
+ function isLabelmapActorEntry(entry) {
46997
+ return entry.excludeFromFidelity === true;
46998
+ }
46999
+
47000
+ __webpack_require__.d(__webpack_exports__, {
47001
+ O: () => (isLabelmapActorEntry)
47002
+ });
47003
+
47004
+
47005
+ },
47006
+ 3508(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
47007
+ "use strict";
47008
+ /* import */ var _enums_Events_js__rspack_import_0 = __webpack_require__(33635);
47009
+ /* import */ var _utilities_triggerEvent_js__rspack_import_1 = __webpack_require__(84444);
47010
+ /* import */ var _buildViewportFidelityState_js__rspack_import_2 = __webpack_require__(22617);
47011
+
47012
+
47013
+
47014
+ const lastKeys = new WeakMap();
47015
+ function notifyFidelityStateChanged(viewport, lines, displaySpacing) {
47016
+ const state = (0,_buildViewportFidelityState_js__rspack_import_2/* .buildViewportFidelityState */.m)(lines, displaySpacing);
47017
+ const key = (0,_buildViewportFidelityState_js__rspack_import_2/* .viewportFidelityStateKey */.B)(state);
47018
+ if (lastKeys.get(viewport) === key) {
47019
+ return;
47020
+ }
47021
+ lastKeys.set(viewport, key);
47022
+ if (viewport.suppressEvents) {
47023
+ return;
47024
+ }
47025
+ const eventDetail = {
47026
+ viewportId: viewport.id,
47027
+ renderingEngineId: viewport.renderingEngineId,
47028
+ state,
47029
+ };
47030
+ (0,_utilities_triggerEvent_js__rspack_import_1/* ["default"] */.A)(viewport.element, _enums_Events_js__rspack_import_0/* ["default"].VIEWPORT_FIDELITY_CHANGED */.A.VIEWPORT_FIDELITY_CHANGED, eventDetail);
47031
+ }
47032
+
47033
+ __webpack_require__.d(__webpack_exports__, {
47034
+ t: () => (notifyFidelityStateChanged)
47035
+ });
47036
+
47037
+
46111
47038
  },
46112
47039
  22761(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
46113
47040
  "use strict";
@@ -46401,12 +47328,16 @@ __webpack_require__.d(__webpack_exports__, {
46401
47328
  y: () => (/* binding */ stats_StatsOverlay)
46402
47329
  });
46403
47330
 
47331
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/cache/cache.js
47332
+ var cache = __webpack_require__(73998);
46404
47333
  // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/renderingEngineCache.js
46405
47334
  var renderingEngineCache = __webpack_require__(91878);
47335
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/enums/ImageQualityStatus.js
47336
+ var ImageQualityStatus = __webpack_require__(7330);
46406
47337
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/helpers/stats/constants.js
46407
47338
  const PANEL_CONFIG = {
46408
47339
  WIDTH: 160,
46409
- WIDE_WIDTH: 360,
47340
+ WIDE_WIDTH: 311,
46410
47341
  HEIGHT: 96,
46411
47342
  TEXT_PADDING: 3,
46412
47343
  TEXT_Y_OFFSET: 2,
@@ -46435,6 +47366,26 @@ const STATS_CONFIG = {
46435
47366
  gap: '4px',
46436
47367
  maxWidth: 'calc(100vw - 8px)',
46437
47368
  userSelect: 'none',
47369
+ paddingTop: '22px',
47370
+ },
47371
+ CLOSE_BUTTON_STYLES: {
47372
+ position: 'absolute',
47373
+ top: '0px',
47374
+ right: '0px',
47375
+ width: '20px',
47376
+ height: '20px',
47377
+ padding: '0',
47378
+ margin: '0',
47379
+ border: '1px solid rgba(255, 255, 255, 0.35)',
47380
+ borderRadius: '3px',
47381
+ background: 'rgba(0, 0, 0, 0.75)',
47382
+ color: '#fff',
47383
+ font: '14px/18px Helvetica, Arial, sans-serif',
47384
+ cursor: 'pointer',
47385
+ zIndex: '1',
47386
+ display: 'flex',
47387
+ alignItems: 'center',
47388
+ justifyContent: 'center',
46438
47389
  },
46439
47390
  POSITION_STORAGE_KEY: 'cornerstone-stats-overlay-position',
46440
47391
  };
@@ -46467,12 +47418,13 @@ var enums_PanelType;
46467
47418
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/helpers/stats/RenderModesPanel.js
46468
47419
 
46469
47420
 
47421
+
46470
47422
  class RenderModesPanel {
46471
47423
  constructor() {
46472
47424
  const config = PANEL_CONFIGS[enums_PanelType.RENDER_MODES];
46473
47425
  this.dom = document.createElement('div');
46474
47426
  this.dom.style.cssText = `
46475
- width:min(720px, max(${PANEL_CONFIG.WIDE_WIDTH}px, calc(100vw - ${PANEL_CONFIG.WIDTH + 24}px)));
47427
+ width:min(622px, max(${PANEL_CONFIG.WIDE_WIDTH}px, calc(100vw - ${PANEL_CONFIG.WIDTH + 24}px)));
46476
47428
  min-width:0;
46477
47429
  min-height:${PANEL_CONFIG.HEIGHT}px;
46478
47430
  background:${config.backgroundColor};
@@ -46516,6 +47468,7 @@ class RenderModesPanel {
46516
47468
  }
46517
47469
  for (const entry of entries) {
46518
47470
  const bindings = orderBindings(entry.bindings);
47471
+ const volumes = entry.volumes ?? [];
46519
47472
  const section = document.createElement('div');
46520
47473
  section.style.cssText = `
46521
47474
  padding:7px;
@@ -46570,7 +47523,7 @@ class RenderModesPanel {
46570
47523
  }
46571
47524
  heading.appendChild(left);
46572
47525
  const count = document.createElement('span');
46573
- count.textContent = `${bindings.length} binding${bindings.length === 1 ? '' : 's'}`;
47526
+ count.textContent = `${bindings.length} binding${bindings.length === 1 ? '' : 's'} · ${volumes.length} vol${volumes.length === 1 ? '' : 's'}`;
46574
47527
  count.style.cssText = `
46575
47528
  flex:0 0 auto;
46576
47529
  color:#c9b05a;
@@ -46579,7 +47532,7 @@ class RenderModesPanel {
46579
47532
  `;
46580
47533
  heading.appendChild(count);
46581
47534
  section.appendChild(heading);
46582
- if (!bindings.length) {
47535
+ if (!bindings.length && !volumes.length) {
46583
47536
  section.appendChild(createEmptyState('(no bindings)'));
46584
47537
  this.list.appendChild(section);
46585
47538
  continue;
@@ -46587,6 +47540,9 @@ class RenderModesPanel {
46587
47540
  for (const binding of bindings) {
46588
47541
  section.appendChild(createBindingRow(binding));
46589
47542
  }
47543
+ for (const volume of volumes) {
47544
+ section.appendChild(createVoxelQualityRow(volume));
47545
+ }
46590
47546
  this.list.appendChild(section);
46591
47547
  }
46592
47548
  }
@@ -46675,7 +47631,7 @@ function createBindingRow(binding) {
46675
47631
  if (binding.referencedId &&
46676
47632
  binding.referencedId !== binding.dataId &&
46677
47633
  binding.referencedId !== binding.actorUID) {
46678
- appendField(fields, 'ref', binding.referencedId, 76);
47634
+ appendField(fields, 'reference', binding.referencedId, 76);
46679
47635
  }
46680
47636
  if (binding.scalarType) {
46681
47637
  appendField(fields, 'type', formatScalarType(binding.scalarType, binding.numberOfComponents), 40);
@@ -46686,6 +47642,94 @@ function createBindingRow(binding) {
46686
47642
  row.appendChild(fields);
46687
47643
  return row;
46688
47644
  }
47645
+ function createVoxelQualityRow(volume) {
47646
+ const row = document.createElement('div');
47647
+ row.style.cssText = `
47648
+ display:grid;
47649
+ grid-template-columns:74px minmax(0, 1fr);
47650
+ gap:8px;
47651
+ padding:6px;
47652
+ margin-top:4px;
47653
+ background:rgba(153, 204, 255, 0.06);
47654
+ border:1px solid rgba(153, 204, 255, 0.18);
47655
+ border-radius:4px;
47656
+ `;
47657
+ const badge = document.createElement('div');
47658
+ badge.textContent = 'QUALITY';
47659
+ badge.style.cssText = `
47660
+ align-self:start;
47661
+ padding:3px 5px;
47662
+ background:rgba(0, 104, 126, 0.28);
47663
+ border:1px solid rgba(153, 204, 255, 0.4);
47664
+ border-radius:3px;
47665
+ color:#9cf;
47666
+ font-size:${PANEL_CONFIG.FONT_SIZE}px;
47667
+ font-weight:800;
47668
+ letter-spacing:0.04em;
47669
+ text-align:center;
47670
+ `;
47671
+ row.appendChild(badge);
47672
+ const fields = document.createElement('div');
47673
+ fields.style.cssText = `
47674
+ display:flex;
47675
+ flex-direction:column;
47676
+ gap:3px;
47677
+ min-width:0;
47678
+ `;
47679
+ const { record } = volume;
47680
+ if (!record) {
47681
+ fields.appendChild(createEmptyState('(no VoxelQualityRecord)'));
47682
+ row.appendChild(fields);
47683
+ return row;
47684
+ }
47685
+ appendField(fields, 'reduction', String(record.reduction), 40);
47686
+ appendField(fields, 'source', String(record.source), 40);
47687
+ appendField(fields, 'status', formatQualityRange(record.status, record.lowest, record.highest), 64);
47688
+ appendField(fields, 'missing', formatMissing(record.missing, record.voxels, record.exact), 48);
47689
+ appendField(fields, 'grid', formatSpacing(record.grid?.spacing), 48);
47690
+ appendField(fields, 'deliveries', String(record.deliveries ?? 0), 24);
47691
+ row.appendChild(fields);
47692
+ return row;
47693
+ }
47694
+ function formatQualityRange(status, lowest, highest) {
47695
+ const summary = formatQualityStatus(status);
47696
+ if (lowest === undefined ||
47697
+ highest === undefined ||
47698
+ (lowest === status && highest === status)) {
47699
+ return summary;
47700
+ }
47701
+ return `${summary} [${formatQualityStatus(lowest)}..${formatQualityStatus(highest)}]`;
47702
+ }
47703
+ function formatQualityStatus(status) {
47704
+ if (status === undefined) {
47705
+ return '-';
47706
+ }
47707
+ return ImageQualityStatus/* ["default"] */.A[status] ?? String(status);
47708
+ }
47709
+ function formatMissing(missing, voxels, exact) {
47710
+ if (!(voxels > 0)) {
47711
+ return '0/0';
47712
+ }
47713
+ const pct = Math.round((100 * missing) / voxels);
47714
+ const approx = exact ? '' : '~';
47715
+ return `${approx}${missing}/${voxels} (${approx}${pct}%)`;
47716
+ }
47717
+ function formatSpacing(spacing) {
47718
+ if (!spacing?.length) {
47719
+ return '-';
47720
+ }
47721
+ return spacing
47722
+ .map((value) => {
47723
+ if (!Number.isFinite(value)) {
47724
+ return '?';
47725
+ }
47726
+ if (Number.isInteger(value)) {
47727
+ return String(value);
47728
+ }
47729
+ return Number(value.toFixed(3)).toString();
47730
+ })
47731
+ .join('×');
47732
+ }
46689
47733
  function formatScalarType(scalarType, numberOfComponents) {
46690
47734
  const friendly = scalarType.replace(/Array$/, '');
46691
47735
  return numberOfComponents && numberOfComponents > 1
@@ -46705,7 +47749,7 @@ function appendField(parent, label, value, maxLength) {
46705
47749
  const field = document.createElement('div');
46706
47750
  field.style.cssText = `
46707
47751
  display:grid;
46708
- grid-template-columns:42px minmax(0, 1fr);
47752
+ grid-template-columns:88px minmax(0, 1fr);
46709
47753
  gap:6px;
46710
47754
  min-width:0;
46711
47755
  `;
@@ -46853,6 +47897,7 @@ var logger = __webpack_require__(34040);
46853
47897
 
46854
47898
 
46855
47899
 
47900
+
46856
47901
  const log = logger.coreLog.getLogger('RenderingEngine', 'StatsOverlay');
46857
47902
  class StatsOverlay {
46858
47903
  constructor() {
@@ -46888,6 +47933,7 @@ class StatsOverlay {
46888
47933
  this.lastUpdateTime = this.startTime;
46889
47934
  this.initializePanels();
46890
47935
  this.applyOverlayStyles();
47936
+ this.addCloseButton();
46891
47937
  this.restorePosition();
46892
47938
  this.attachDragHandlers();
46893
47939
  document.body.appendChild(this.dom);
@@ -46921,6 +47967,27 @@ class StatsOverlay {
46921
47967
  applyOverlayStyles() {
46922
47968
  Object.assign(this.dom.style, STATS_CONFIG.OVERLAY_STYLES);
46923
47969
  }
47970
+ addCloseButton() {
47971
+ if (!this.dom) {
47972
+ return;
47973
+ }
47974
+ const close = document.createElement('button');
47975
+ close.type = 'button';
47976
+ close.setAttribute('aria-label', 'Close stats overlay');
47977
+ close.title = 'Close';
47978
+ close.textContent = '×';
47979
+ Object.assign(close.style, STATS_CONFIG.CLOSE_BUTTON_STYLES);
47980
+ close.addEventListener('pointerdown', (event) => {
47981
+ event.stopPropagation();
47982
+ event.preventDefault();
47983
+ });
47984
+ close.addEventListener('click', (event) => {
47985
+ event.stopPropagation();
47986
+ event.preventDefault();
47987
+ this.cleanup();
47988
+ });
47989
+ this.dom.appendChild(close);
47990
+ }
46924
47991
  initializePanels() {
46925
47992
  this.initializePanelColumns();
46926
47993
  const fpsPanel = new StatsPanel(PANEL_CONFIGS[enums_PanelType.FPS].name, PANEL_CONFIGS[enums_PanelType.FPS].foregroundColor, PANEL_CONFIGS[enums_PanelType.FPS].backgroundColor);
@@ -47001,6 +48068,7 @@ class StatsOverlay {
47001
48068
  if (!(panel instanceof RenderModesPanel)) {
47002
48069
  return;
47003
48070
  }
48071
+ const qualityByVolumeId = new Map();
47004
48072
  const entries = [];
47005
48073
  for (const renderingEngine of renderingEngineCache/* ["default"].getAll */.A.getAll()) {
47006
48074
  if (!renderingEngine || renderingEngine.hasBeenDestroyed) {
@@ -47009,11 +48077,22 @@ class StatsOverlay {
47009
48077
  for (const viewport of renderingEngine.getViewports()) {
47010
48078
  const debugViewport = viewport;
47011
48079
  const renderModes = debugViewport._debug?.renderModes;
48080
+ const volumeIds = this.collectViewportVolumeIds(debugViewport);
48081
+ const volumes = volumeIds.map((volumeId) => {
48082
+ if (!qualityByVolumeId.has(volumeId)) {
48083
+ qualityByVolumeId.set(volumeId, this.readVoxelQuality(volumeId));
48084
+ }
48085
+ return {
48086
+ volumeId,
48087
+ record: qualityByVolumeId.get(volumeId),
48088
+ };
48089
+ });
47012
48090
  entries.push({
47013
48091
  renderingEngineId: renderingEngine.id,
47014
48092
  viewportId: viewport.id,
47015
48093
  viewportType: viewport.type,
47016
48094
  bindings: this.getViewportBindingDebugEntries(debugViewport, renderModes ?? {}),
48095
+ volumes,
47017
48096
  });
47018
48097
  }
47019
48098
  }
@@ -47051,6 +48130,37 @@ class StatsOverlay {
47051
48130
  };
47052
48131
  });
47053
48132
  }
48133
+ collectViewportVolumeIds(viewport) {
48134
+ const ids = [];
48135
+ const seen = new Set();
48136
+ const push = (candidate) => {
48137
+ if (!candidate || seen.has(candidate)) {
48138
+ return;
48139
+ }
48140
+ if (!cache/* ["default"].getVolume */.Ay.getVolume(candidate)) {
48141
+ return;
48142
+ }
48143
+ seen.add(candidate);
48144
+ ids.push(candidate);
48145
+ };
48146
+ push(viewport.getSourceDataId?.());
48147
+ for (const actor of viewport.getActors?.() ?? []) {
48148
+ push(actor.referencedId);
48149
+ }
48150
+ return ids;
48151
+ }
48152
+ readVoxelQuality(volumeId) {
48153
+ try {
48154
+ const volume = cache/* ["default"].getVolume */.Ay.getVolume(volumeId);
48155
+ if (typeof volume?.getVoxelQuality !== 'function') {
48156
+ return undefined;
48157
+ }
48158
+ return volume.getVoxelQuality();
48159
+ }
48160
+ catch {
48161
+ return undefined;
48162
+ }
48163
+ }
47054
48164
  updateMemoryPanel() {
47055
48165
  const memPanel = this.panels.get(enums_PanelType.MEMORY);
47056
48166
  if (!memPanel) {
@@ -47076,6 +48186,10 @@ class StatsOverlay {
47076
48186
  if (!this.dom || event.button !== 0) {
47077
48187
  return;
47078
48188
  }
48189
+ if (event.target instanceof Element &&
48190
+ event.target.closest('button[aria-label="Close stats overlay"]')) {
48191
+ return;
48192
+ }
47079
48193
  this.dragPointerId = event.pointerId;
47080
48194
  const rect = this.dom.getBoundingClientRect();
47081
48195
  this.dragOffsetX = event.clientX - rect.left;
@@ -47701,6 +48815,27 @@ const newInstance = _kitware_vtk_js_macros_js__rspack_import_0/* ["default"].new
47701
48815
  /* export default */ __webpack_exports__.Ay = ({ newInstance, extend });
47702
48816
 
47703
48817
 
48818
+ },
48819
+ 92090(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
48820
+ "use strict";
48821
+ function takeBoundScalarTexture(model) {
48822
+ const texture = model.renderable.getScalarTexture?.();
48823
+ if (!model.scalarTextures) {
48824
+ model.scalarTextures = [];
48825
+ }
48826
+ if (texture && texture !== model.scalarTextures[0]) {
48827
+ model.scalarTextures[0] = texture;
48828
+ if (model.scalarTextureStrings) {
48829
+ model.scalarTextureStrings[0] = undefined;
48830
+ }
48831
+ }
48832
+ }
48833
+
48834
+ __webpack_require__.d(__webpack_exports__, {
48835
+ A: () => (takeBoundScalarTexture)
48836
+ });
48837
+
48838
+
47704
48839
  },
47705
48840
  18462(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
47706
48841
  "use strict";
@@ -50765,16 +51900,25 @@ var Property_Constants = __webpack_require__(63643);
50765
51900
  var VolumeMapper_Constants = __webpack_require__(43449);
50766
51901
  // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/init.js + 1 modules
50767
51902
  var init = __webpack_require__(90934);
51903
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/cache/cache.js
51904
+ var cache_cache = __webpack_require__(73998);
50768
51905
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/vtkClasses/canUseFloatOpacityTexture.js
50769
- function canUseFloatOpacityTexture(openGLRenderWindow, context) {
50770
- const supportsFloatTextures = openGLRenderWindow.getWebgl2() ||
50771
- Boolean(context.getExtension('OES_texture_float'));
50772
- const supportsFloatLinearFiltering = Boolean(context.getExtension('OES_texture_float_linear'));
50773
- return supportsFloatTextures && supportsFloatLinearFiltering;
51906
+ function canUseFloatOpacityTexture(context) {
51907
+ return Boolean(context.getExtension('OES_texture_float_linear'));
50774
51908
  }
50775
51909
 
51910
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/vtkClasses/takeBoundScalarTexture.js
51911
+ var takeBoundScalarTexture = __webpack_require__(92090);
51912
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/helpers/actorsWaitingForStorage.js
51913
+ var actorsWaitingForStorage = __webpack_require__(72667);
50776
51914
  // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/logger.js
50777
51915
  var logger = __webpack_require__(34040);
51916
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/getBufferConfiguration.js
51917
+ var getBufferConfiguration = __webpack_require__(25752);
51918
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/voxelGrid/index.js + 5 modules
51919
+ var voxelGrid = __webpack_require__(49617);
51920
+ // EXTERNAL MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/utilities/gpuSettingsPresets.js
51921
+ var gpuSettingsPresets = __webpack_require__(701);
50778
51922
  ;// CONCATENATED MODULE: ../../node_modules/@cornerstonejs/core/dist/esm/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js
50779
51923
 
50780
51924
 
@@ -50788,7 +51932,36 @@ var logger = __webpack_require__(34040);
50788
51932
 
50789
51933
 
50790
51934
 
51935
+
51936
+
51937
+
51938
+
51939
+
51940
+
50791
51941
  const log = logger.coreLog.getLogger('RenderingEngine', 'vtkStreamingOpenGLVolumeMapper');
51942
+ const warnedKeys = new Set();
51943
+ function gridFitsGpuSettings(dims, dataType, numberOfComponents, context) {
51944
+ const gpuSettings = (0,gpuSettingsPresets/* .gpuSettingsForRender */.je)();
51945
+ if (!gpuSettings || numberOfComponents > 1 || context?.dynamic) {
51946
+ return true;
51947
+ }
51948
+ const limits = (0,gpuSettingsPresets/* .gridLimitsOfGpuSettings */.B$)(gpuSettings, (0,getBufferConfiguration/* .volumeTextureBytes */.Bw)(1, dataType, numberOfComponents));
51949
+ const grid = {
51950
+ dimensions: [dims[0], dims[1], dims[2]],
51951
+ spacing: [1, 1, 1],
51952
+ origin: [0, 0, 0],
51953
+ direction: [1, 0, 0, 0, 1, 0, 0, 0, 1],
51954
+ };
51955
+ if ((0,voxelGrid.voxelGridWithinLimits)(grid, limits)) {
51956
+ return true;
51957
+ }
51958
+ const key = `${context?.volumeId}|${grid.dimensions}|${gpuSettings.id}|${limits.maxEdge}|${limits.maxVoxelCount}`;
51959
+ if (!warnedKeys.has(key)) {
51960
+ warnedKeys.add(key);
51961
+ log.warn(`the GPU settings preset ${gpuSettings.id} cannot hold a texture of ${dims[0]}x${dims[1]}x${dims[2]} for the volume ${context?.volumeId}, so no allocation is issued`);
51962
+ }
51963
+ return false;
51964
+ }
50792
51965
  function vtkStreamingOpenGLVolumeMapper(publicAPI, model) {
50793
51966
  model.classHierarchy.push('vtkStreamingOpenGLVolumeMapper');
50794
51967
  const graphicsResourceReferenceCount = new Map();
@@ -50872,7 +52045,13 @@ function vtkStreamingOpenGLVolumeMapper(publicAPI, model) {
50872
52045
  return;
50873
52046
  }
50874
52047
  publicAPI.renderPieceStart(ren, actor);
50875
- publicAPI.renderPieceDraw(ren, actor);
52048
+ if (model.scalarTextures.some((texture) => texture?.isInitializing?.())) {
52049
+ actorsWaitingForStorage/* ["default"].set */.A.set(actor, performance.now());
52050
+ }
52051
+ else {
52052
+ actorsWaitingForStorage/* ["default"]["delete"] */.A["delete"](actor);
52053
+ publicAPI.renderPieceDraw(ren, actor);
52054
+ }
50876
52055
  publicAPI.renderPieceFinish(ren, actor);
50877
52056
  };
50878
52057
  publicAPI.buildBufferObjects = (ren, actor) => {
@@ -50930,7 +52109,7 @@ function vtkStreamingOpenGLVolumeMapper(publicAPI, model) {
50930
52109
  newOpacityTexture.resetFormatAndType();
50931
52110
  newOpacityTexture.setMinificationFilter(Texture_Constants/* .Filter.LINEAR */.dJ.LINEAR);
50932
52111
  newOpacityTexture.setMagnificationFilter(Texture_Constants/* .Filter.LINEAR */.dJ.LINEAR);
50933
- if (canUseFloatOpacityTexture(model._openGLRenderWindow, model.context)) {
52112
+ if (canUseFloatOpacityTexture(model.context)) {
50934
52113
  newOpacityTexture.create2DFromRaw({
50935
52114
  width: oWidth,
50936
52115
  height: 2 * numIComps,
@@ -51007,6 +52186,7 @@ function vtkStreamingOpenGLVolumeMapper(publicAPI, model) {
51007
52186
  }
51008
52187
  replaceGraphicsResource(model._openGLRenderWindow, model._colorTextureCore, firstColorTransferFunc);
51009
52188
  model._colorTextureCore = firstColorTransferFunc;
52189
+ (0,takeBoundScalarTexture/* ["default"] */.A)(model);
51010
52190
  model.currentValidInputs.forEach(({ imageData, inputIndex: _inputIndex }, component) => {
51011
52191
  if (!model.scalarTextures) {
51012
52192
  model.scalarTextures = [];
@@ -51021,7 +52201,7 @@ function vtkStreamingOpenGLVolumeMapper(publicAPI, model) {
51021
52201
  model.scalarTextureStrings = [];
51022
52202
  }
51023
52203
  if (model.scalarTextureStrings[component] !== toString) {
51024
- const dims = imageData.getDimensions();
52204
+ const dims = currentTexture.getGrid?.()?.dimensions ?? imageData.getDimensions();
51025
52205
  currentTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
51026
52206
  currentTexture.enableUseHalfFloat(false);
51027
52207
  const previousTextureParameters = currentTexture.getTextureParameters();
@@ -51043,6 +52223,15 @@ function vtkStreamingOpenGLVolumeMapper(publicAPI, model) {
51043
52223
  }
51044
52224
  }
51045
52225
  if (shouldReset) {
52226
+ if (!gridFitsGpuSettings(dims, dataType, textureNumberOfComponents, {
52227
+ volumeId: currentTexture.getVolumeId?.(),
52228
+ dynamic: cache_cache/* ["default"] */.Ay
52229
+ .getVolume(currentTexture.getVolumeId?.())
52230
+ ?.isDynamicVolume?.(),
52231
+ })) {
52232
+ currentTexture.deactivate();
52233
+ return;
52234
+ }
51046
52235
  const norm16Ext = model.context.getExtension('EXT_texture_norm16');
51047
52236
  currentTexture.setOglNorm16Ext((0,init/* .getCanUseNorm16Texture */.up)() ? norm16Ext : null);
51048
52237
  currentTexture.resetFormatAndType();
@@ -52521,6 +53710,10 @@ function vtkSlabCamera(publicAPI, model) {
52521
53710
  /* import */ var _kitware_vtk_js_Rendering_OpenGL_RenderWindow_resourceSharingHelper_js__rspack_import_5 = __webpack_require__(89671);
52522
53711
  /* import */ var _kitware_vtk_js_Rendering_OpenGL_Texture_js__rspack_import_6 = __webpack_require__(74830);
52523
53712
  /* import */ var _init_js__rspack_import_7 = __webpack_require__(90934);
53713
+ /* import */ var _takeBoundScalarTexture_js__rspack_import_8 = __webpack_require__(92090);
53714
+ /* import */ var _helpers_actorsWaitingForStorage_js__rspack_import_9 = __webpack_require__(72667);
53715
+
53716
+
52524
53717
 
52525
53718
 
52526
53719
 
@@ -52608,7 +53801,13 @@ function vtkStreamingOpenGLImageResliceMapper(publicAPI, model) {
52608
53801
  : (firstScalars?.getNumberOfComponents?.() ?? 1);
52609
53802
  publicAPI.updateResliceGeometry();
52610
53803
  publicAPI.renderPieceStart(ren, actor);
52611
- publicAPI.renderPieceDraw(ren, actor);
53804
+ if (model.scalarTextures?.some((texture) => texture?.isInitializing?.())) {
53805
+ _helpers_actorsWaitingForStorage_js__rspack_import_9/* ["default"].set */.A.set(actor, performance.now());
53806
+ }
53807
+ else {
53808
+ _helpers_actorsWaitingForStorage_js__rspack_import_9/* ["default"]["delete"] */.A["delete"](actor);
53809
+ publicAPI.renderPieceDraw(ren, actor);
53810
+ }
52612
53811
  publicAPI.renderPieceFinish(ren, actor);
52613
53812
  publicAPI.invokeEvent({ type: 'EndEvent' });
52614
53813
  };
@@ -52643,6 +53842,7 @@ function vtkStreamingOpenGLImageResliceMapper(publicAPI, model) {
52643
53842
  };
52644
53843
  publicAPI.buildBufferObjects = (ren, actor) => {
52645
53844
  const actorProperties = actor.getProperties();
53845
+ (0,_takeBoundScalarTexture_js__rspack_import_8/* ["default"] */.A)(model);
52646
53846
  model.currentValidInputs.forEach(({ imageData }, component) => {
52647
53847
  if (!model.scalarTextures) {
52648
53848
  model.scalarTextures = [];
@@ -52656,7 +53856,7 @@ function vtkStreamingOpenGLImageResliceMapper(publicAPI, model) {
52656
53856
  const hasUpdatedExtents = !!updatedExtents.length;
52657
53857
  const canStream = currentTexture && typeof currentTexture.hasUpdatedFrames === 'function';
52658
53858
  if (canStream) {
52659
- const dims = imageData.getDimensions();
53859
+ const dims = currentTexture.getGrid?.()?.dimensions ?? imageData.getDimensions();
52660
53860
  const { dataType } = imageData.get('dataType');
52661
53861
  const numComps = model.numberOfComponents;
52662
53862
  currentTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
@@ -52950,12 +54150,40 @@ const newInstance = _kitware_vtk_js_macros_js__rspack_import_0/* ["default"].new
52950
54150
  /* import */ var _kitware_vtk_js_Rendering_OpenGL_Texture_js__rspack_import_1 = __webpack_require__(74830);
52951
54151
  /* import */ var _cache_cache_js__rspack_import_2 = __webpack_require__(73998);
52952
54152
  /* import */ var _utilities_getBufferConfiguration_js__rspack_import_3 = __webpack_require__(25752);
54153
+ /* import */ var _utilities_VoxelManager_js__rspack_import_4 = __webpack_require__(60719);
54154
+ /* import */ var _utilities_voxelGrid_index_js__rspack_import_5 = __webpack_require__(49617);
54155
+ /* import */ var _utilities_voxelGrid_voxelStatistics_js__rspack_import_6 = __webpack_require__(40210);
54156
+ /* import */ var _utilities_voxelGrid_boxSpan_js__rspack_import_7 = __webpack_require__(9844);
54157
+ /* import */ var _enums_VoxelStatistics_js__rspack_import_8 = __webpack_require__(10475);
54158
+ /* import */ var _enums_ImageQualityStatus_js__rspack_import_9 = __webpack_require__(7330);
54159
+ /* import */ var _utilities_autoLoad_js__rspack_import_10 = __webpack_require__(38795);
54160
+ /* import */ var _init_js__rspack_import_11 = __webpack_require__(90934);
54161
+
54162
+
54163
+
54164
+
54165
+
54166
+
52953
54167
 
52954
54168
 
52955
54169
 
52956
54170
 
54171
+
54172
+
54173
+ const DEFAULT_MAX_SLICES_PER_RENDER = 16;
54174
+ const DEFAULT_MAX_MILLISECONDS_PER_RENDER = 8;
54175
+ const INIT_FENCE_MIN_BYTES = 256 * 1024 * 1024;
54176
+ const INIT_FENCE_DEADLINE_MS = 3000;
54177
+ const INIT_FENCE_POLL_MS = 16;
54178
+ function reducedTextureFillBudget() {
54179
+ const budget = (0,_init_js__rspack_import_11/* .getConfiguration */.D0)()?.rendering?.reducedTextureFill;
54180
+ return {
54181
+ maxSlicesPerRender: Math.max(1, budget?.maxSlicesPerRender ?? DEFAULT_MAX_SLICES_PER_RENDER),
54182
+ maxMillisecondsPerRender: budget?.maxMillisecondsPerRender ?? DEFAULT_MAX_MILLISECONDS_PER_RENDER,
54183
+ };
54184
+ }
52957
54185
  function convertDataType(data, targetDataType) {
52958
- const Constructor = (0,_utilities_getBufferConfiguration_js__rspack_import_3/* .getConstructorFromType */.j)(targetDataType);
54186
+ const Constructor = (0,_utilities_getBufferConfiguration_js__rspack_import_3/* .getConstructorFromType */.j5)(targetDataType);
52959
54187
  const convertedData = new Constructor(data.length);
52960
54188
  convertedData.set(data);
52961
54189
  return convertedData;
@@ -52964,6 +54192,10 @@ function vtkStreamingOpenGLTexture(publicAPI, model) {
52964
54192
  model.classHierarchy.push('vtkStreamingOpenGLTexture');
52965
54193
  model.updatedFrames = [];
52966
54194
  model.volumeId = null;
54195
+ model.fillCursor = 0;
54196
+ model.remainingFillScheduled = false;
54197
+ model.grid = null;
54198
+ model.statistic = null;
52967
54199
  const superCreate3DFilterableFromRaw = publicAPI.create3DFilterableFromRaw;
52968
54200
  publicAPI.create3DFilterableFromRaw = ({ width, height, depth, numberOfComponents, dataType, data, preferSizeOverAccuracy, }) => {
52969
54201
  model.inputDataType = dataType;
@@ -52978,6 +54210,99 @@ function vtkStreamingOpenGLTexture(publicAPI, model) {
52978
54210
  preferSizeOverAccuracy,
52979
54211
  });
52980
54212
  };
54213
+ const superCreate3DFromRaw = publicAPI.create3DFromRaw;
54214
+ publicAPI.create3DFromRaw = (options) => {
54215
+ const created = superCreate3DFromRaw(options);
54216
+ if (created && !options.data) {
54217
+ model.writtenSlices = new Uint8Array(options.depth);
54218
+ startStorageInit(options.dataType, options.numComps);
54219
+ publicAPI.markAllFramesUpdated();
54220
+ }
54221
+ return created;
54222
+ };
54223
+ function startStorageInit(dataType, numComps) {
54224
+ releaseInitFence();
54225
+ const gl = model.context;
54226
+ if (typeof gl?.fenceSync !== 'function' ||
54227
+ !(model.allocatedGPUMemoryInBytes >= INIT_FENCE_MIN_BYTES)) {
54228
+ return;
54229
+ }
54230
+ let pixData;
54231
+ try {
54232
+ const Constructor = (0,_utilities_getBufferConfiguration_js__rspack_import_3/* .getConstructorFromType */.j5)(dataType, false);
54233
+ [pixData] = publicAPI.updateArrayDataTypeForGL(dataType, [
54234
+ new Constructor(numComps || 1),
54235
+ ]);
54236
+ }
54237
+ catch {
54238
+ return;
54239
+ }
54240
+ model._openGLRenderWindow.activateTexture(publicAPI);
54241
+ publicAPI.bind();
54242
+ gl.texSubImage3D(model.target, 0, 0, 0, 0, 1, 1, 1, model.format, model.openGLDataType, pixData);
54243
+ publicAPI.deactivate();
54244
+ const sync = gl.fenceSync(gl.SYNC_GPU_COMMANDS_COMPLETE, 0);
54245
+ if (!sync) {
54246
+ return;
54247
+ }
54248
+ const fence = {
54249
+ gl,
54250
+ sync,
54251
+ deadline: performance.now() + INIT_FENCE_DEADLINE_MS,
54252
+ };
54253
+ model.initFence = fence;
54254
+ gl.flush();
54255
+ model.initFenceTimer = setTimeout(() => pollInitFence(fence), INIT_FENCE_POLL_MS);
54256
+ }
54257
+ function releaseInitFence(keepPoll = false) {
54258
+ const fence = model.initFence;
54259
+ if (!keepPoll) {
54260
+ clearTimeout(model.initFenceTimer);
54261
+ model.initFenceTimer = null;
54262
+ }
54263
+ model.initFence = null;
54264
+ if (fence && !fence.gl.isContextLost()) {
54265
+ fence.gl.deleteSync(fence.sync);
54266
+ }
54267
+ }
54268
+ function pollInitFence(fence) {
54269
+ if (model.deleted || (model.initFence && model.initFence !== fence)) {
54270
+ return;
54271
+ }
54272
+ if (publicAPI.isInitializing()) {
54273
+ model.initFenceTimer = setTimeout(() => pollInitFence(fence), INIT_FENCE_POLL_MS);
54274
+ return;
54275
+ }
54276
+ publicAPI.modified();
54277
+ if (model.volumeId) {
54278
+ (0,_utilities_autoLoad_js__rspack_import_10/* ["default"] */.A)(model.volumeId);
54279
+ }
54280
+ }
54281
+ publicAPI.isInitializing = () => {
54282
+ const fence = model.initFence;
54283
+ if (!fence) {
54284
+ return false;
54285
+ }
54286
+ const { gl, sync, deadline } = fence;
54287
+ if (!gl.isContextLost() &&
54288
+ performance.now() < deadline &&
54289
+ gl.getSyncParameter(sync, gl.SYNC_STATUS) !== gl.SIGNALED) {
54290
+ return true;
54291
+ }
54292
+ releaseInitFence(true);
54293
+ return false;
54294
+ };
54295
+ const superReleaseGraphicsResources = publicAPI.releaseGraphicsResources;
54296
+ publicAPI.releaseGraphicsResources = (rwin) => {
54297
+ const window = model._openGLRenderWindow;
54298
+ releaseInitFence();
54299
+ superReleaseGraphicsResources(rwin ?? (window?.isDeleted?.() ? undefined : window));
54300
+ };
54301
+ const superDelete = publicAPI.delete;
54302
+ publicAPI.delete = () => {
54303
+ releaseInitFence();
54304
+ superDelete();
54305
+ };
52981
54306
  const superUpdate = publicAPI.updateVolumeInfoForGL;
52982
54307
  publicAPI.updateVolumeInfoForGL = (dataType, numComps) => {
52983
54308
  const isScalingApplied = superUpdate(dataType, numComps);
@@ -52991,7 +54316,7 @@ function vtkStreamingOpenGLTexture(publicAPI, model) {
52991
54316
  return;
52992
54317
  }
52993
54318
  const volume = _cache_cache_js__rspack_import_2/* ["default"].getVolume */.Ay.getVolume(volumeId);
52994
- if (!volume) {
54319
+ if (!volume || publicAPI.isInitializing()) {
52995
54320
  return;
52996
54321
  }
52997
54322
  model._openGLRenderWindow.activateTexture(publicAPI);
@@ -53001,23 +54326,251 @@ function vtkStreamingOpenGLTexture(publicAPI, model) {
53001
54326
  updateDynamicVolumeTexture();
53002
54327
  return;
53003
54328
  }
54329
+ if (model.grid && !isGridOfVolume(volume, model.grid)) {
54330
+ return publicAPI.hasUpdatedFrames() && updateTextureFromComposite(volume);
54331
+ }
53004
54332
  return (publicAPI.hasUpdatedFrames() && updateTextureImagesUsingVoxelManager());
53005
54333
  };
53006
- const superModified = publicAPI.modified;
54334
+ function isGridOfVolume(volume, grid) {
54335
+ return volume.voxelGrid ? (0,_utilities_voxelGrid_index_js__rspack_import_5.voxelGridsEqual)(volume.voxelGrid, grid) : true;
54336
+ }
54337
+ function boxFactorsOf(volume, grid) {
54338
+ const volumeGrid = volume.voxelGrid;
54339
+ if (!volumeGrid) {
54340
+ return null;
54341
+ }
54342
+ const factors = [];
54343
+ for (let axis = 0; axis < 3; axis++) {
54344
+ for (let index = 0; index < 3; index++) {
54345
+ if (Math.abs(grid.direction[axis * 3 + index] -
54346
+ volumeGrid.direction[axis * 3 + index]) > 1e-6) {
54347
+ return null;
54348
+ }
54349
+ }
54350
+ const ratio = grid.spacing[axis] / volumeGrid.spacing[axis];
54351
+ const extentRatio = volumeGrid.dimensions[axis] / grid.dimensions[axis];
54352
+ if (!(ratio > 1 - 1e-6)) {
54353
+ return null;
54354
+ }
54355
+ factors.push(Math.abs(ratio - extentRatio) <= 1e-6 * extentRatio
54356
+ ? extentRatio
54357
+ : ratio);
54358
+ }
54359
+ return factors;
54360
+ }
54361
+ function framesOfSlice(volume, factorK, slice) {
54362
+ const [sourceWidth, sourceHeight, sourceDepth] = volume.dimensions;
54363
+ const voxelManager = volume.voxelManager;
54364
+ const span = (0,_utilities_voxelGrid_boxSpan_js__rspack_import_7/* .spanOfBox */.z1)(0, factorK, sourceDepth, slice);
54365
+ const firstK = span.first;
54366
+ if (!voxelManager?.getSliceData || firstK >= sourceDepth) {
54367
+ return null;
54368
+ }
54369
+ const lastK = span.end;
54370
+ const centre = (firstK + lastK - 1) / 2;
54371
+ const loaded = [];
54372
+ const replicates = [];
54373
+ for (let k = firstK; k < lastK; k++) {
54374
+ const quality = volume.getImageQuality
54375
+ ? volume.getImageQuality(k)
54376
+ : _enums_ImageQualityStatus_js__rspack_import_9/* ["default"].FULL_RESOLUTION */.A.FULL_RESOLUTION;
54377
+ if (quality >= _enums_ImageQualityStatus_js__rspack_import_9/* ["default"].SUBRESOLUTION */.A.SUBRESOLUTION) {
54378
+ loaded.push(k);
54379
+ }
54380
+ else if (quality) {
54381
+ replicates.push(k);
54382
+ }
54383
+ }
54384
+ const indices = loaded.length ? loaded : nearestTo(centre, replicates);
54385
+ const frameLength = sourceWidth * sourceHeight;
54386
+ const frames = [];
54387
+ const weights = [];
54388
+ for (const k of indices) {
54389
+ const frame = readFrame(volume, k, frameLength);
54390
+ if (frame) {
54391
+ frames.push(frame);
54392
+ weights.push((0,_utilities_voxelGrid_boxSpan_js__rspack_import_7/* .weightInSpan */.Oj)(span, k));
54393
+ }
54394
+ }
54395
+ return { frames, weights };
54396
+ }
54397
+ function nearestTo(centre, indices) {
54398
+ let best = Infinity;
54399
+ for (const index of indices) {
54400
+ best = Math.min(best, Math.abs(index - centre));
54401
+ }
54402
+ return indices.filter((index) => Math.abs(index - centre) === best);
54403
+ }
54404
+ function readFrame(volume, k, frameLength) {
54405
+ const imageId = volume.imageIds?.[k];
54406
+ const image = imageId ? _cache_cache_js__rspack_import_2/* ["default"].getImage */.Ay.getImage(imageId) : undefined;
54407
+ if (imageId && !image) {
54408
+ return null;
54409
+ }
54410
+ let frame = image?.voxelManager?.getScalarData();
54411
+ if (!frame || frame.length < frameLength) {
54412
+ try {
54413
+ frame = volume.voxelManager.getSliceData({
54414
+ sliceIndex: k,
54415
+ slicePlane: 2,
54416
+ });
54417
+ }
54418
+ catch {
54419
+ frame = null;
54420
+ }
54421
+ }
54422
+ return frame && frame.length >= frameLength ? frame : null;
54423
+ }
54424
+ function statisticOf(volume) {
54425
+ return (model.statistic ?? volume.reductionStatistic ?? _enums_VoxelStatistics_js__rspack_import_8/* ["default"].Average */.A.Average);
54426
+ }
54427
+ function fillSliceByBoxStatistic(volume, grid, factors, slice, target) {
54428
+ const { fillPlane } = (0,_utilities_voxelGrid_voxelStatistics_js__rspack_import_6/* .requireVoxelStatistic */.Qk)(statisticOf(volume));
54429
+ if (!fillPlane) {
54430
+ return false;
54431
+ }
54432
+ const [factorI, factorJ, factorK] = factors;
54433
+ const { frames, weights } = framesOfSlice(volume, factorK, slice) ?? {};
54434
+ if (!frames?.length) {
54435
+ return false;
54436
+ }
54437
+ fillPlane(frames, [volume.dimensions[0], volume.dimensions[1]], [grid.dimensions[0], grid.dimensions[1]], [factorI, factorJ], target.getScalarData(), weights);
54438
+ return true;
54439
+ }
54440
+ function derivedSliceReaderOf(composite, grid, statistic) {
54441
+ const representation = composite.getRepresentation(grid, statistic ?? _enums_VoxelStatistics_js__rspack_import_8/* ["default"].Average */.A.Average);
54442
+ const [width, height, depth] = grid.dimensions;
54443
+ const frameLength = width * height;
54444
+ if (!representation) {
54445
+ return null;
54446
+ }
54447
+ const { imageIds } = representation;
54448
+ if (imageIds?.length === depth) {
54449
+ return (slice) => _cache_cache_js__rspack_import_2/* ["default"] */.Ay.getImage(imageIds[slice])?.voxelManager?.getScalarData();
54450
+ }
54451
+ const voxels = representation.voxelManager?.getWritableScalarData?.();
54452
+ if (voxels?.length !== frameLength * depth) {
54453
+ return null;
54454
+ }
54455
+ return (slice) => voxels.subarray(slice * frameLength, (slice + 1) * frameLength);
54456
+ }
54457
+ function scheduleRemainingFill() {
54458
+ if (model.remainingFillScheduled) {
54459
+ return;
54460
+ }
54461
+ model.remainingFillScheduled = true;
54462
+ setTimeout(() => {
54463
+ model.remainingFillScheduled = false;
54464
+ if (!model.volumeId || !publicAPI.hasUpdatedFrames()) {
54465
+ return;
54466
+ }
54467
+ publicAPI.modified();
54468
+ (0,_utilities_autoLoad_js__rspack_import_10/* ["default"] */.A)(model.volumeId);
54469
+ }, 0);
54470
+ }
54471
+ function markWritten(slice) {
54472
+ if (model.writtenSlices) {
54473
+ model.writtenSlices[slice] = 1;
54474
+ }
54475
+ }
54476
+ function updateTextureFromComposite(volume) {
54477
+ const { grid } = model;
54478
+ const [width, height, depth] = grid.dimensions;
54479
+ const Constructor = (0,_utilities_getBufferConfiguration_js__rspack_import_3/* .getConstructorFromType */.j5)(volume.dataType, false);
54480
+ const frameLength = width * height;
54481
+ const composite = volume.compositeVoxelManager;
54482
+ const gl = model.context;
54483
+ const statistic = statisticOf(volume);
54484
+ const derivedSliceOf = derivedSliceReaderOf(composite, grid, statistic);
54485
+ const factors = boxFactorsOf(volume, grid);
54486
+ const slab = _utilities_VoxelManager_js__rspack_import_4/* ["default"].createScalarVolumeVoxelManager */.A.createScalarVolumeVoxelManager({
54487
+ dimensions: [width, height, 1],
54488
+ scalarData: new Constructor(frameLength),
54489
+ numberOfComponents: 1,
54490
+ });
54491
+ const { maxSlicesPerRender, maxMillisecondsPerRender } = reducedTextureFillBudget();
54492
+ const startTime = performance.now();
54493
+ let slicesHandled = 0;
54494
+ let slicesWithData = 0;
54495
+ let stoppedEarly = false;
54496
+ for (let step = 0; step < depth; step++) {
54497
+ const slice = (model.fillCursor + step) % depth;
54498
+ if (!model.updatedFrames[slice]) {
54499
+ continue;
54500
+ }
54501
+ if (slicesWithData >= maxSlicesPerRender ||
54502
+ (slicesHandled &&
54503
+ performance.now() - startTime >= maxMillisecondsPerRender)) {
54504
+ model.fillCursor = slice;
54505
+ stoppedEarly = true;
54506
+ break;
54507
+ }
54508
+ let data = derivedSliceOf?.(slice);
54509
+ let hasData = !!data;
54510
+ if (!data) {
54511
+ slab.getScalarData().fill(0);
54512
+ const filled = factors &&
54513
+ fillSliceByBoxStatistic(volume, grid, factors, slice, slab);
54514
+ hasData = !!filled || !factors;
54515
+ if (!filled && !factors) {
54516
+ composite.fillGrid({
54517
+ dimensions: [width, height, 1],
54518
+ spacing: grid.spacing,
54519
+ direction: grid.direction,
54520
+ origin: [
54521
+ grid.origin[0] + grid.direction[6] * grid.spacing[2] * slice,
54522
+ grid.origin[1] + grid.direction[7] * grid.spacing[2] * slice,
54523
+ grid.origin[2] + grid.direction[8] * grid.spacing[2] * slice,
54524
+ ],
54525
+ }, slab, statistic);
54526
+ }
54527
+ data = slab.getScalarData();
54528
+ }
54529
+ if (!hasData && model.writtenSlices && !model.writtenSlices[slice]) {
54530
+ model.updatedFrames[slice] = null;
54531
+ continue;
54532
+ }
54533
+ if (volume.dataType !== data.constructor.name) {
54534
+ data = convertDataType(data, volume.dataType);
54535
+ }
54536
+ const [pixData] = publicAPI.updateArrayDataTypeForGL(volume.dataType, [
54537
+ data,
54538
+ ]);
54539
+ publicAPI.bind();
54540
+ gl.texSubImage3D(model.target, 0, 0, 0, slice, width, height, 1, model.format, model.openGLDataType, pixData);
54541
+ publicAPI.deactivate();
54542
+ model.updatedFrames[slice] = null;
54543
+ markWritten(slice);
54544
+ slicesHandled++;
54545
+ if (hasData) {
54546
+ slicesWithData++;
54547
+ }
54548
+ }
54549
+ if (stoppedEarly) {
54550
+ scheduleRemainingFill();
54551
+ }
54552
+ if (model.generateMipmap) {
54553
+ model.context.generateMipmap(model.target);
54554
+ }
54555
+ publicAPI.deactivate();
54556
+ return true;
54557
+ }
53007
54558
  publicAPI.setUpdatedFrame = (frameIndex) => {
53008
54559
  model.updatedFrames[frameIndex] = true;
53009
- superModified();
54560
+ publicAPI.modified();
53010
54561
  };
53011
- publicAPI.modified = () => {
53012
- superModified();
54562
+ publicAPI.markAllFramesUpdated = () => {
53013
54563
  const volume = _cache_cache_js__rspack_import_2/* ["default"].getVolume */.Ay.getVolume(model.volumeId);
53014
54564
  if (!volume) {
53015
54565
  return;
53016
54566
  }
53017
- const imageIds = volume.imageIds;
53018
- for (let i = 0; i < imageIds.length; i++) {
54567
+ const slices = model.grid
54568
+ ? model.grid.dimensions[2]
54569
+ : volume.imageIds.length;
54570
+ for (let i = 0; i < slices; i++) {
53019
54571
  model.updatedFrames[i] = true;
53020
54572
  }
54573
+ publicAPI.modified();
53021
54574
  };
53022
54575
  function updateTextureImagesUsingVoxelManager() {
53023
54576
  const volume = _cache_cache_js__rspack_import_2/* ["default"].getVolume */.Ay.getVolume(model.volumeId);
@@ -53030,6 +54583,21 @@ function vtkStreamingOpenGLTexture(publicAPI, model) {
53030
54583
  }
53031
54584
  let data = image.voxelManager.getScalarData();
53032
54585
  const gl = model.context;
54586
+ if (data.length !==
54587
+ model.width * model.height * (model.components || 1)) {
54588
+ try {
54589
+ data = volume.voxelManager.getSliceData({
54590
+ sliceIndex: i,
54591
+ slicePlane: 2,
54592
+ });
54593
+ }
54594
+ catch {
54595
+ data = null;
54596
+ }
54597
+ if (!data) {
54598
+ continue;
54599
+ }
54600
+ }
53033
54601
  if (volume.dataType !== data.constructor.name) {
53034
54602
  data = convertDataType(data, volume.dataType);
53035
54603
  }
@@ -53060,8 +54628,11 @@ function vtkStreamingOpenGLTexture(publicAPI, model) {
53060
54628
  const imageId = imageIds[i];
53061
54629
  const image = _cache_cache_js__rspack_import_2/* ["default"].getImage */.Ay.getImage(imageId);
53062
54630
  let data;
54631
+ if (!image && model.writtenSlices && !model.writtenSlices[i]) {
54632
+ continue;
54633
+ }
53063
54634
  if (!image) {
53064
- constructor = (0,_utilities_getBufferConfiguration_js__rspack_import_3/* .getConstructorFromType */.j)(volume.dataType, true);
54635
+ constructor = (0,_utilities_getBufferConfiguration_js__rspack_import_3/* .getConstructorFromType */.j5)(volume.dataType, true);
53065
54636
  data = new constructor(model.width * model.height);
53066
54637
  }
53067
54638
  else {
@@ -53079,6 +54650,7 @@ function vtkStreamingOpenGLTexture(publicAPI, model) {
53079
54650
  let zOffset = i;
53080
54651
  gl.texSubImage3D(model.target, 0, 0, 0, zOffset, model.width, model.height, 1, model.format, model.openGLDataType, pixData);
53081
54652
  publicAPI.deactivate();
54653
+ markWritten(i);
53082
54654
  }
53083
54655
  if (model.generateMipmap) {
53084
54656
  model.context.generateMipmap(model.target);
@@ -53087,11 +54659,33 @@ function vtkStreamingOpenGLTexture(publicAPI, model) {
53087
54659
  return true;
53088
54660
  }
53089
54661
  publicAPI.hasUpdatedFrames = () => !model.updatedFrames.length || model.updatedFrames.some((frame) => frame);
54662
+ publicAPI.setFillHint = (slice) => {
54663
+ const depth = model.grid?.dimensions[2];
54664
+ if (depth && Number.isFinite(slice)) {
54665
+ model.fillCursor = Math.min(depth - 1, Math.max(0, Math.round(slice)));
54666
+ }
54667
+ };
54668
+ publicAPI.isFillPending = () => {
54669
+ const volume = model.volumeId ? _cache_cache_js__rspack_import_2/* ["default"].getVolume */.Ay.getVolume(model.volumeId) : null;
54670
+ return (!!volume &&
54671
+ !!model.grid &&
54672
+ !volume.isDynamicVolume?.() &&
54673
+ !isGridOfVolume(volume, model.grid) &&
54674
+ model.updatedFrames.some((frame) => frame));
54675
+ };
53090
54676
  publicAPI.getUpdatedFrames = () => model.updatedFrames;
53091
54677
  publicAPI.setVolumeId = (volumeId) => {
53092
54678
  model.volumeId = volumeId;
53093
54679
  };
53094
54680
  publicAPI.getVolumeId = () => model.volumeId;
54681
+ publicAPI.setGrid = (grid) => {
54682
+ model.grid = grid;
54683
+ };
54684
+ publicAPI.getGrid = () => model.grid;
54685
+ publicAPI.setStatistic = (statistic) => {
54686
+ model.statistic = statistic;
54687
+ };
54688
+ publicAPI.getStatistic = () => model.statistic;
53095
54689
  publicAPI.setTextureParameters = ({ width, height, depth, numberOfComponents, dataType, }) => {
53096
54690
  model.width ??= width;
53097
54691
  model.height ??= height;
@@ -53146,6 +54740,7 @@ class Cache {
53146
54740
  this._referencedImageIdToImageIdCache = new Map();
53147
54741
  this._geometryCache = new Map();
53148
54742
  this._imageCacheSize = 0;
54743
+ this._imageGeneration = 0;
53149
54744
  this._maxCacheSize = 3 * ONE_GB;
53150
54745
  this._geometryCacheSize = 0;
53151
54746
  this.setMaxCacheSize = (newMaxCacheSize) => {
@@ -53206,13 +54801,10 @@ class Cache {
53206
54801
  if (volumeLoadObject.cancelFn) {
53207
54802
  volumeLoadObject.cancelFn();
53208
54803
  }
53209
- if (volume.imageIds) {
53210
- volume.imageIds.forEach((imageId) => {
53211
- const cachedImage = this._imageCache.get(imageId);
53212
- if (cachedImage && cachedImage.sharedCacheKey === volumeId) {
53213
- cachedImage.sharedCacheKey = undefined;
53214
- }
53215
- });
54804
+ for (const cachedImage of this._imageCache.values()) {
54805
+ if (cachedImage.sharedCacheKey === volumeId) {
54806
+ cachedImage.sharedCacheKey = undefined;
54807
+ }
53216
54808
  }
53217
54809
  this._volumeCache.delete(volumeId);
53218
54810
  };
@@ -53514,6 +55106,7 @@ class Cache {
53514
55106
  this.decacheIfNecessaryUntilBytesAvailable(image.sizeInBytes);
53515
55107
  cachedImage.loaded = true;
53516
55108
  cachedImage.image = image;
55109
+ this._imageGeneration++;
53517
55110
  cachedImage.sizeInBytes = image.sizeInBytes;
53518
55111
  this.incrementImageCacheSize(cachedImage.sizeInBytes);
53519
55112
  const eventDetails = {
@@ -53619,12 +55212,9 @@ class Cache {
53619
55212
  const imageIdToUse = (0,_utilities_imageIdToURI_js__rspack_import_1/* ["default"] */.A)(imageId);
53620
55213
  for (const volumeId of volumeIds) {
53621
55214
  const cachedVolume = this._volumeCache.get(volumeId);
53622
- if (!cachedVolume) {
53623
- return;
53624
- }
53625
- const { volume } = cachedVolume;
53626
- if (!volume.imageIds.length) {
53627
- return;
55215
+ const volume = cachedVolume?.volume;
55216
+ if (!volume?.imageIds?.length) {
55217
+ continue;
53628
55218
  }
53629
55219
  const imageIdIndex = volume.getImageURIIndex(imageIdToUse);
53630
55220
  if (imageIdIndex > -1) {
@@ -53643,6 +55233,12 @@ class Cache {
53643
55233
  }
53644
55234
  return this._imageCache.get(foundImageId);
53645
55235
  }
55236
+ setImageSharedCacheKey(imageId, sharedCacheKey) {
55237
+ const cachedImage = this._imageCache.get(imageId);
55238
+ if (cachedImage) {
55239
+ cachedImage.sharedCacheKey = sharedCacheKey;
55240
+ }
55241
+ }
53646
55242
  _putVolumeCommon(volumeId, volume, cachedVolume) {
53647
55243
  if (!this._volumeCache.get(volumeId)) {
53648
55244
  log.warn('The volume was purged from the cache before it completed loading.');
@@ -53779,6 +55375,9 @@ class Cache {
53779
55375
  }
53780
55376
  }
53781
55377
  setPartialImage(imageId, partialImage, removeImageLoadObject = false) {
55378
+ if (partialImage) {
55379
+ this._imageGeneration++;
55380
+ }
53782
55381
  const cachedImage = this._imageCache.get(imageId);
53783
55382
  if (!cachedImage) {
53784
55383
  if (partialImage) {
@@ -53806,6 +55405,9 @@ class Cache {
53806
55405
  cachedImage.image = partialImage || cachedImage.image;
53807
55406
  }
53808
55407
  }
55408
+ getImageGeneration() {
55409
+ return this._imageGeneration;
55410
+ }
53809
55411
  getImageQuality(imageId) {
53810
55412
  const image = this._imageCache.get(imageId)?.image;
53811
55413
  return image
@@ -53825,16 +55427,20 @@ const cache = new Cache();
53825
55427
  /* import */ var _enums_index_js__rspack_import_1 = __webpack_require__(71088);
53826
55428
  /* import */ var _eventTarget_js__rspack_import_2 = __webpack_require__(45340);
53827
55429
  /* import */ var _requestPool_imageLoadPoolManager_js__rspack_import_3 = __webpack_require__(7799);
53828
- /* import */ var _utilities_ProgressiveIterator_js__rspack_import_4 = __webpack_require__(56783);
53829
- /* import */ var _utilities_imageRetrieveMetadataProvider_js__rspack_import_5 = __webpack_require__(95071);
53830
- /* import */ var _utilities_hasFloatScalingParameters_js__rspack_import_6 = __webpack_require__(8985);
53831
- /* import */ var _utilities_autoLoad_js__rspack_import_7 = __webpack_require__(38795);
53832
- /* import */ var _utilities_triggerEvent_js__rspack_import_8 = __webpack_require__(84444);
53833
- /* import */ var _ImageVolume_js__rspack_import_9 = __webpack_require__(19564);
53834
- /* import */ var _loaders_ProgressiveRetrieveImages_js__rspack_import_10 = __webpack_require__(82655);
53835
- /* import */ var _init_js__rspack_import_11 = __webpack_require__(90934);
53836
- /* import */ var _loaders_imageLoader_js__rspack_import_12 = __webpack_require__(65092);
53837
- /* import */ var _utilities_logger_js__rspack_import_13 = __webpack_require__(34040);
55430
+ /* import */ var _utilities_voxelGrid_index_js__rspack_import_4 = __webpack_require__(49617);
55431
+ /* import */ var _cache_js__rspack_import_5 = __webpack_require__(73998);
55432
+ /* import */ var _utilities_ProgressiveIterator_js__rspack_import_6 = __webpack_require__(56783);
55433
+ /* import */ var _utilities_imageRetrieveMetadataProvider_js__rspack_import_7 = __webpack_require__(95071);
55434
+ /* import */ var _utilities_hasFloatScalingParameters_js__rspack_import_8 = __webpack_require__(8985);
55435
+ /* import */ var _utilities_autoLoad_js__rspack_import_9 = __webpack_require__(38795);
55436
+ /* import */ var _utilities_triggerEvent_js__rspack_import_10 = __webpack_require__(84444);
55437
+ /* import */ var _ImageVolume_js__rspack_import_11 = __webpack_require__(19564);
55438
+ /* import */ var _loaders_ProgressiveRetrieveImages_js__rspack_import_12 = __webpack_require__(82655);
55439
+ /* import */ var _init_js__rspack_import_13 = __webpack_require__(90934);
55440
+ /* import */ var _loaders_imageLoader_js__rspack_import_14 = __webpack_require__(65092);
55441
+ /* import */ var _utilities_logger_js__rspack_import_15 = __webpack_require__(34040);
55442
+
55443
+
53838
55444
 
53839
55445
 
53840
55446
 
@@ -53849,9 +55455,10 @@ const cache = new Cache();
53849
55455
 
53850
55456
 
53851
55457
 
53852
- const log = _utilities_logger_js__rspack_import_13.coreLog.getLogger('cache', 'BaseStreamingImageVolume');
55458
+ const log = _utilities_logger_js__rspack_import_15.coreLog.getLogger('cache', 'BaseStreamingImageVolume');
53853
55459
  const requestTypeDefault = _enums_index_js__rspack_import_1.RequestType.Prefetch;
53854
- class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["default"] */.A {
55460
+ const TAKE_IN_BATCH_MS = 8;
55461
+ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_11/* ["default"] */.Ay {
53855
55462
  constructor(imageVolumeProperties, streamingProperties) {
53856
55463
  super(imageVolumeProperties);
53857
55464
  this.framesLoaded = 0;
@@ -53861,6 +55468,8 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
53861
55468
  this.cachedFrames = [];
53862
55469
  this.reRenderTarget = 0;
53863
55470
  this.reRenderFraction = 2;
55471
+ this.markOnImageCached = null;
55472
+ this.takeInGeneration = 0;
53864
55473
  this.imagesLoader = this;
53865
55474
  this.cancelLoading = () => {
53866
55475
  const { loadStatus } = this;
@@ -53869,23 +55478,31 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
53869
55478
  }
53870
55479
  loadStatus.loading = false;
53871
55480
  loadStatus.cancelled = true;
55481
+ this.stopListeningForCachedImages();
53872
55482
  this.clearLoadCallbacks();
53873
55483
  const filterFunction = ({ additionalDetails }) => {
53874
55484
  return additionalDetails.volumeId !== this.volumeId;
53875
55485
  };
53876
55486
  _requestPool_imageLoadPoolManager_js__rspack_import_3/* ["default"].filterRequests */.A.filterRequests(filterFunction);
55487
+ (0,_utilities_triggerEvent_js__rspack_import_10/* ["default"] */.A)(_eventTarget_js__rspack_import_2/* ["default"] */.A, _enums_index_js__rspack_import_1.Events.IMAGE_VOLUME_LOADING_CANCELLED, {
55488
+ volumeId: this.volumeId,
55489
+ });
53877
55490
  };
53878
55491
  this.loadStatus = streamingProperties.loadStatus;
53879
55492
  }
55493
+ isInCurrentDimensionGroup(_imageIdIndex) {
55494
+ return true;
55495
+ }
53880
55496
  invalidateVolume(immediate) {
53881
- const { vtkOpenGLTexture } = this;
53882
55497
  const { numFrames } = this;
55498
+ this.resetCompositeVoxelManager();
53883
55499
  for (let i = 0; i < numFrames; i++) {
53884
- vtkOpenGLTexture.setUpdatedFrame(i);
55500
+ this.voxelManager?.invalidateSlice?.(i);
53885
55501
  }
55502
+ this.markAllTexturesDirty();
53886
55503
  this.modified();
53887
55504
  if (immediate) {
53888
- (0,_utilities_autoLoad_js__rspack_import_7/* ["default"] */.A)(this.volumeId);
55505
+ (0,_utilities_autoLoad_js__rspack_import_9/* ["default"] */.A)(this.volumeId);
53889
55506
  }
53890
55507
  }
53891
55508
  clearLoadCallbacks() {
@@ -53899,7 +55516,7 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
53899
55516
  if (framesUpdated > this.reRenderTarget ||
53900
55517
  framesProcessed === totalNumFrames) {
53901
55518
  this.reRenderTarget += reRenderFraction;
53902
- (0,_utilities_autoLoad_js__rspack_import_7/* ["default"] */.A)(volumeId);
55519
+ (0,_utilities_autoLoad_js__rspack_import_9/* ["default"] */.A)(volumeId);
53903
55520
  }
53904
55521
  }
53905
55522
  if (framesProcessed === totalNumFrames) {
@@ -53908,18 +55525,19 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
53908
55525
  FrameOfReferenceUID,
53909
55526
  volumeId: volumeId,
53910
55527
  };
53911
- (0,_utilities_triggerEvent_js__rspack_import_8/* ["default"] */.A)(_eventTarget_js__rspack_import_2/* ["default"] */.A, _enums_index_js__rspack_import_1.Events.IMAGE_VOLUME_LOADING_COMPLETED, eventDetail);
55528
+ this.stopListeningForCachedImages();
55529
+ (0,_utilities_triggerEvent_js__rspack_import_10/* ["default"] */.A)(_eventTarget_js__rspack_import_2/* ["default"] */.A, _enums_index_js__rspack_import_1.Events.IMAGE_VOLUME_LOADING_COMPLETED, eventDetail);
53912
55530
  }
53913
55531
  }
53914
55532
  updateTextureAndTriggerEvents(imageIdIndex, imageId, imageQualityStatus = _enums_index_js__rspack_import_1.ImageQualityStatus.FULL_RESOLUTION) {
53915
55533
  const frameIndex = this.imageIdIndexToFrameIndex(imageIdIndex);
53916
55534
  const { cachedFrames, numFrames, totalNumFrames } = this;
53917
55535
  const { FrameOfReferenceUID } = this.metadata;
53918
- const currentStatus = cachedFrames[frameIndex];
55536
+ const currentStatus = cachedFrames[imageIdIndex];
53919
55537
  if (currentStatus > imageQualityStatus) {
53920
55538
  return;
53921
55539
  }
53922
- if (cachedFrames[frameIndex] === _enums_index_js__rspack_import_1.ImageQualityStatus.FULL_RESOLUTION) {
55540
+ if (cachedFrames[imageIdIndex] === _enums_index_js__rspack_import_1.ImageQualityStatus.FULL_RESOLUTION) {
53923
55541
  return;
53924
55542
  }
53925
55543
  const complete = imageQualityStatus === _enums_index_js__rspack_import_1.ImageQualityStatus.FULL_RESOLUTION;
@@ -53935,7 +55553,7 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
53935
55553
  numberOfFrames: numFrames,
53936
55554
  framesProcessed: this.framesProcessed,
53937
55555
  };
53938
- (0,_utilities_triggerEvent_js__rspack_import_8/* ["default"] */.A)(_eventTarget_js__rspack_import_2/* ["default"] */.A, _enums_index_js__rspack_import_1.Events.IMAGE_VOLUME_MODIFIED, eventDetail);
55556
+ (0,_utilities_triggerEvent_js__rspack_import_10/* ["default"] */.A)(_eventTarget_js__rspack_import_2/* ["default"] */.A, _enums_index_js__rspack_import_1.Events.IMAGE_VOLUME_MODIFIED, eventDetail);
53939
55557
  if (complete && this.framesProcessed === this.totalNumFrames) {
53940
55558
  this.loadStatus.loaded = true;
53941
55559
  this.loadStatus.loading = false;
@@ -53952,11 +55570,41 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
53952
55570
  complete,
53953
55571
  imageQualityStatus,
53954
55572
  });
53955
- this.vtkOpenGLTexture.setUpdatedFrame(frameIndex);
55573
+ this.markFrameTexturesDirty(frameIndex);
55574
+ if (this.isInCurrentDimensionGroup(imageIdIndex)) {
55575
+ this.recordFrameDelivery(frameIndex, imageQualityStatus);
55576
+ }
53956
55577
  if (this.loadStatus.loaded) {
53957
55578
  this.loadStatus.callbacks = [];
53958
55579
  }
53959
55580
  }
55581
+ listenForCachedImages() {
55582
+ if (this.markOnImageCached) {
55583
+ return;
55584
+ }
55585
+ this.markOnImageCached = (event) => {
55586
+ const { imageId } = event.detail?.image ?? {};
55587
+ const imageIdIndex = imageId ? this.getImageIdIndex(imageId) : -1;
55588
+ if (imageIdIndex < 0) {
55589
+ return;
55590
+ }
55591
+ const frameIndex = this.imageIdIndexToFrameIndex(imageIdIndex);
55592
+ const quality = this.cachedFrames[imageIdIndex];
55593
+ this.markFrameTexturesDirty(frameIndex);
55594
+ if (quality !== undefined &&
55595
+ this.isInCurrentDimensionGroup(imageIdIndex)) {
55596
+ this.recordFrameDelivery(frameIndex, quality);
55597
+ }
55598
+ };
55599
+ _eventTarget_js__rspack_import_2/* ["default"].addEventListener */.A.addEventListener(_enums_index_js__rspack_import_1.Events.IMAGE_CACHE_IMAGE_ADDED, this.markOnImageCached);
55600
+ }
55601
+ stopListeningForCachedImages() {
55602
+ if (!this.markOnImageCached) {
55603
+ return;
55604
+ }
55605
+ _eventTarget_js__rspack_import_2/* ["default"].removeEventListener */.A.removeEventListener(_enums_index_js__rspack_import_1.Events.IMAGE_CACHE_IMAGE_ADDED, this.markOnImageCached);
55606
+ this.markOnImageCached = null;
55607
+ }
53960
55608
  successCallback(imageId, image) {
53961
55609
  const imageIdIndex = this.getImageIdIndex(imageId);
53962
55610
  const { imageQualityStatus } = image;
@@ -53999,17 +55647,17 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
53999
55647
  imageIdIndex,
54000
55648
  imageId,
54001
55649
  };
54002
- (0,_utilities_triggerEvent_js__rspack_import_8/* ["default"] */.A)(_eventTarget_js__rspack_import_2/* ["default"] */.A, _enums_index_js__rspack_import_1.Events.IMAGE_LOAD_ERROR, eventDetail);
55650
+ (0,_utilities_triggerEvent_js__rspack_import_10/* ["default"] */.A)(_eventTarget_js__rspack_import_2/* ["default"] */.A, _enums_index_js__rspack_import_1.Events.IMAGE_LOAD_ERROR, eventDetail);
54003
55651
  }
54004
55652
  load(callback) {
54005
55653
  const { imageIds, loadStatus, numFrames } = this;
54006
55654
  const { transferSyntaxUID } = _metaData_js__rspack_import_0.get(_enums_index_js__rspack_import_1.MetadataModules.TRANSFER_SYNTAX, imageIds[0]) || {};
54007
- const imageRetrieveConfiguration = _metaData_js__rspack_import_0.get(_utilities_imageRetrieveMetadataProvider_js__rspack_import_5/* ["default"].IMAGE_RETRIEVE_CONFIGURATION */.A.IMAGE_RETRIEVE_CONFIGURATION, this.volumeId, transferSyntaxUID, 'volume');
55655
+ const imageRetrieveConfiguration = _metaData_js__rspack_import_0.get(_utilities_imageRetrieveMetadataProvider_js__rspack_import_7/* ["default"].IMAGE_RETRIEVE_CONFIGURATION */.A.IMAGE_RETRIEVE_CONFIGURATION, this.volumeId, transferSyntaxUID, 'volume');
54008
55656
  this.imagesLoader = this.isDynamicVolume()
54009
55657
  ? this
54010
55658
  : imageRetrieveConfiguration
54011
55659
  ? (imageRetrieveConfiguration.create ||
54012
- _loaders_ProgressiveRetrieveImages_js__rspack_import_10/* ["default"].createProgressive */.Ay.createProgressive)(imageRetrieveConfiguration)
55660
+ _loaders_ProgressiveRetrieveImages_js__rspack_import_12/* ["default"].createProgressive */.Ay.createProgressive)(imageRetrieveConfiguration)
54013
55661
  : this;
54014
55662
  if (loadStatus.loading === true) {
54015
55663
  return;
@@ -54028,15 +55676,80 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
54028
55676
  }
54029
55677
  return;
54030
55678
  }
55679
+ this.listenForCachedImages();
54031
55680
  if (callback) {
54032
55681
  this.loadStatus.callbacks.push(callback);
54033
55682
  }
54034
55683
  this._prefetchImageIds();
55684
+ if (this.isLoadingProgressively()) {
55685
+ this.removeOtherPrefetchRequests();
55686
+ }
55687
+ this.takeInCachedImages();
55688
+ }
55689
+ takeInCachedImages() {
55690
+ if (this.isDynamicVolume()) {
55691
+ return;
55692
+ }
55693
+ const generation = ++this.takeInGeneration;
55694
+ const { imageIds } = this;
55695
+ let imageIdIndex = 0;
55696
+ const deliverBatch = () => {
55697
+ if (generation !== this.takeInGeneration ||
55698
+ this.loadStatus.cancelled ||
55699
+ !this.loadStatus.loading) {
55700
+ return;
55701
+ }
55702
+ const start = performance.now();
55703
+ while (imageIdIndex < imageIds.length) {
55704
+ const imageId = imageIds[imageIdIndex];
55705
+ const image = _cache_js__rspack_import_5/* ["default"].isLoaded */.Ay.isLoaded(imageId)
55706
+ ? _cache_js__rspack_import_5/* ["default"].getImage */.Ay.getImage(imageId)
55707
+ : undefined;
55708
+ if (image && !this.cachedFrames[imageIdIndex]) {
55709
+ this.successCallback(imageId, image);
55710
+ }
55711
+ imageIdIndex++;
55712
+ if (performance.now() - start >= TAKE_IN_BATCH_MS) {
55713
+ break;
55714
+ }
55715
+ }
55716
+ if (imageIdIndex < imageIds.length) {
55717
+ setTimeout(deliverBatch, 0);
55718
+ }
55719
+ };
55720
+ deliverBatch();
55721
+ }
55722
+ isLoadingProgressively() {
55723
+ return !!this.loadStatus.loading && this.imagesLoader !== this;
55724
+ }
55725
+ removeOtherPrefetchRequests() {
55726
+ const imageIds = new Set(this.imageIds);
55727
+ _requestPool_imageLoadPoolManager_js__rspack_import_3/* ["default"].filterRequests */.A.filterRequests(({ type, additionalDetails }) => type !== _enums_index_js__rspack_import_1.RequestType.Prefetch ||
55728
+ additionalDetails?.volumeId === this.volumeId ||
55729
+ !imageIds.has(additionalDetails?.imageId));
55730
+ }
55731
+ destroy() {
55732
+ this.stopListeningForCachedImages();
55733
+ super.destroy();
55734
+ }
55735
+ getImageQuality(imageIdIndex) {
55736
+ return this.cachedFrames[imageIdIndex] || undefined;
55737
+ }
55738
+ deliveredRegions() {
55739
+ const regions = [];
55740
+ for (let imageIdIndex = 0; imageIdIndex < this.cachedFrames.length; imageIdIndex++) {
55741
+ const quality = this.cachedFrames[imageIdIndex];
55742
+ if (quality && this.isInCurrentDimensionGroup(imageIdIndex)) {
55743
+ regions.push({
55744
+ bounds: (0,_utilities_voxelGrid_index_js__rspack_import_4.boundsOfFrame)(this.voxelGrid, this.imageIdIndexToFrameIndex(imageIdIndex)),
55745
+ quality,
55746
+ });
55747
+ }
55748
+ }
55749
+ return regions;
54035
55750
  }
54036
55751
  getLoaderImageOptions(imageId) {
54037
55752
  const { transferSyntaxUID: transferSyntaxUID } = _metaData_js__rspack_import_0.get(_enums_index_js__rspack_import_1.MetadataModules.TRANSFER_SYNTAX, imageId) || {};
54038
- const targetRows = this.dimensions[1];
54039
- const targetCols = this.dimensions[0];
54040
55753
  const imageIdIndex = this.getImageIdIndex(imageId);
54041
55754
  const modalityLutModule = _metaData_js__rspack_import_0.get(_enums_index_js__rspack_import_1.MetadataModules.MODALITY_LUT, imageId) || {};
54042
55755
  const generalSeriesModule = _metaData_js__rspack_import_0.get(_enums_index_js__rspack_import_1.MetadataModules.GENERAL_SERIES, imageId) || {};
@@ -54053,8 +55766,8 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
54053
55766
  Object.assign(scalingParameters, scalingFactor);
54054
55767
  }
54055
55768
  }
54056
- const floatAfterScale = (0,_utilities_hasFloatScalingParameters_js__rspack_import_6/* .hasFloatScalingParameters */.a)(scalingParameters);
54057
- const allowFloatRendering = (0,_init_js__rspack_import_11/* .canRenderFloatTextures */.lk)();
55769
+ const floatAfterScale = (0,_utilities_hasFloatScalingParameters_js__rspack_import_8/* .hasFloatScalingParameters */.a)(scalingParameters);
55770
+ const allowFloatRendering = (0,_init_js__rspack_import_13/* .canRenderFloatTextures */.lk)();
54058
55771
  this.isPreScaled = true;
54059
55772
  if (scalingParameters &&
54060
55773
  scalingParameters.rescaleSlope !== undefined &&
@@ -54069,8 +55782,6 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
54069
55782
  }
54070
55783
  const targetBuffer = {
54071
55784
  type: this.dataType,
54072
- rows: targetRows,
54073
- columns: targetCols,
54074
55785
  };
54075
55786
  return {
54076
55787
  targetBuffer,
@@ -54095,18 +55806,10 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
54095
55806
  if (cachedFrames[imageIdIndex] === _enums_index_js__rspack_import_1.ImageQualityStatus.FULL_RESOLUTION) {
54096
55807
  return;
54097
55808
  }
54098
- const handleImageCacheAdded = (event) => {
54099
- const { image } = event.detail;
54100
- if (image.imageId === imageId) {
54101
- this.vtkOpenGLTexture.setUpdatedFrame(imageIdIndex);
54102
- _eventTarget_js__rspack_import_2/* ["default"].removeEventListener */.A.removeEventListener(_enums_index_js__rspack_import_1.Events.IMAGE_CACHE_IMAGE_ADDED, handleImageCacheAdded);
54103
- }
54104
- };
54105
- _eventTarget_js__rspack_import_2/* ["default"].addEventListener */.A.addEventListener(_enums_index_js__rspack_import_1.Events.IMAGE_CACHE_IMAGE_ADDED, handleImageCacheAdded);
54106
- const uncompressedIterator = _utilities_ProgressiveIterator_js__rspack_import_4/* ["default"].as */.A.as((0,_loaders_imageLoader_js__rspack_import_12.loadAndCacheImage)(imageId, options));
55809
+ const uncompressedIterator = _utilities_ProgressiveIterator_js__rspack_import_6/* ["default"].as */.A.as((0,_loaders_imageLoader_js__rspack_import_14.loadAndCacheImage)(imageId, options));
54107
55810
  return uncompressedIterator.forEach((image) => {
54108
55811
  this.successCallback(imageId, image);
54109
- }, this.errorCallback.bind(this, imageIdIndex, imageId));
55812
+ }, (error, done) => this.errorCallback(imageId, done, error));
54110
55813
  }
54111
55814
  getImageIdsRequests(imageIds, priorityDefault) {
54112
55815
  this.totalNumFrames = this.imageIds.length;
@@ -54121,7 +55824,7 @@ class BaseStreamingImageVolume extends _ImageVolume_js__rspack_import_9/* ["defa
54121
55824
  const requestType = requestTypeDefault;
54122
55825
  const priority = priorityDefault;
54123
55826
  const options = this.getLoaderImageOptions(imageId);
54124
- const { retrieveOptions = {} } = _metaData_js__rspack_import_0.get(_utilities_imageRetrieveMetadataProvider_js__rspack_import_5/* ["default"].IMAGE_RETRIEVE_CONFIGURATION */.A.IMAGE_RETRIEVE_CONFIGURATION, imageId, 'volume') || {};
55827
+ const { retrieveOptions = {} } = _metaData_js__rspack_import_0.get(_utilities_imageRetrieveMetadataProvider_js__rspack_import_7/* ["default"].IMAGE_RETRIEVE_CONFIGURATION */.A.IMAGE_RETRIEVE_CONFIGURATION, imageId, 'volume') || {};
54125
55828
  options.retrieveOptions = {
54126
55829
  ...options.retrieveOptions,
54127
55830
  ...(retrieveOptions.default ||
@@ -56731,6 +58434,20 @@ const microscopyViewportCss = `
56731
58434
  /* export default */ __webpack_exports__.A = (microscopyViewportCss);
56732
58435
 
56733
58436
 
58437
+ },
58438
+ 7330(__unused_rspack___webpack_module__, __webpack_exports__) {
58439
+ "use strict";
58440
+ var ImageQualityStatus;
58441
+ (function (ImageQualityStatus) {
58442
+ ImageQualityStatus[ImageQualityStatus["FAR_REPLICATE"] = 1] = "FAR_REPLICATE";
58443
+ ImageQualityStatus[ImageQualityStatus["ADJACENT_REPLICATE"] = 3] = "ADJACENT_REPLICATE";
58444
+ ImageQualityStatus[ImageQualityStatus["SUBRESOLUTION"] = 6] = "SUBRESOLUTION";
58445
+ ImageQualityStatus[ImageQualityStatus["LOSSY"] = 7] = "LOSSY";
58446
+ ImageQualityStatus[ImageQualityStatus["FULL_RESOLUTION"] = 8] = "FULL_RESOLUTION";
58447
+ })(ImageQualityStatus || (ImageQualityStatus = {}));
58448
+ /* export default */ __webpack_exports__.A = (ImageQualityStatus);
58449
+
58450
+
56734
58451
  },
56735
58452
  49221(__unused_rspack___webpack_module__, __webpack_exports__) {
56736
58453
  "use strict";
@@ -56743,6 +58460,72 @@ var VOILUTFunctionType;
56743
58460
  /* export default */ __webpack_exports__.A = (VOILUTFunctionType);
56744
58461
 
56745
58462
 
58463
+ },
58464
+ 2568(__unused_rspack___webpack_module__, __webpack_exports__) {
58465
+ "use strict";
58466
+ const builtInVoxelDataSources = {
58467
+ ServerLevel: 'serverLevel',
58468
+ ClientDerived: 'clientDerived',
58469
+ DecoderSubResolution: 'decoderSubResolution',
58470
+ DirectLoad: 'directLoad',
58471
+ };
58472
+ const VoxelDataSources = builtInVoxelDataSources;
58473
+ function registerVoxelDataSourcesConstant(name, source) {
58474
+ if (Object.prototype.hasOwnProperty.call(VoxelDataSources, name)) {
58475
+ throw new Error(`Voxel data source constant "${String(name)}" already exists`);
58476
+ }
58477
+ VoxelDataSources[name] =
58478
+ source;
58479
+ }
58480
+ /* export default */ __webpack_exports__.A = (VoxelDataSources);
58481
+
58482
+
58483
+ },
58484
+ 33170(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
58485
+ "use strict";
58486
+ const builtInVoxelReductions = {
58487
+ None: 'none',
58488
+ BoxAverage: 'boxAverage',
58489
+ BoxForegroundMajority: 'boxForegroundMajority',
58490
+ Decimation: 'decimation',
58491
+ };
58492
+ const VoxelReductions = builtInVoxelReductions;
58493
+ function registerVoxelReductionsConstant(name, reduction) {
58494
+ if (Object.prototype.hasOwnProperty.call(VoxelReductions, name)) {
58495
+ throw new Error(`Voxel reduction constant "${String(name)}" already exists`);
58496
+ }
58497
+ VoxelReductions[name] =
58498
+ reduction;
58499
+ }
58500
+ /* export default */ __webpack_exports__.A = (VoxelReductions);
58501
+
58502
+ __webpack_require__.d(__webpack_exports__, {
58503
+ o: () => (registerVoxelReductionsConstant)
58504
+ });
58505
+
58506
+
58507
+ },
58508
+ 10475(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
58509
+ "use strict";
58510
+ const builtInVoxelStatistics = {
58511
+ Average: 'average',
58512
+ ForegroundMajority: 'foregroundMajority',
58513
+ };
58514
+ const VoxelStatistics = builtInVoxelStatistics;
58515
+ function registerVoxelStatisticsConstant(name, statistic) {
58516
+ if (Object.prototype.hasOwnProperty.call(VoxelStatistics, name)) {
58517
+ throw new Error(`Voxel statistic constant "${String(name)}" already exists`);
58518
+ }
58519
+ VoxelStatistics[name] =
58520
+ statistic;
58521
+ }
58522
+ /* export default */ __webpack_exports__.A = (VoxelStatistics);
58523
+
58524
+ __webpack_require__.d(__webpack_exports__, {
58525
+ F: () => (registerVoxelStatisticsConstant)
58526
+ });
58527
+
58528
+
56746
58529
  },
56747
58530
  45340(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
56748
58531
  "use strict";
@@ -56836,6 +58619,70 @@ const eventTarget = new CornerstoneEventTarget();
56836
58619
  /* export default */ __webpack_exports__.A = (eventTarget);
56837
58620
 
56838
58621
 
58622
+ },
58623
+ 5519(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
58624
+ "use strict";
58625
+ /* import */ var _enums_index_js__rspack_import_0 = __webpack_require__(71088);
58626
+
58627
+ const DECIMATE = 64;
58628
+ const OFFSET_BITS = Math.log2(DECIMATE);
58629
+ function replicateQualityOf(offset) {
58630
+ const distance = Math.abs(offset);
58631
+ return distance <= 1
58632
+ ? _enums_index_js__rspack_import_0.ImageQualityStatus.ADJACENT_REPLICATE
58633
+ : (_enums_index_js__rspack_import_0.ImageQualityStatus.FAR_REPLICATE + 1 / distance);
58634
+ }
58635
+ function nearbyFramesOfDecimation(decimate) {
58636
+ const frames = [];
58637
+ const first = -Math.floor((decimate - 1) / 2);
58638
+ for (let offset = first; offset < first + decimate; offset++) {
58639
+ if (offset !== 0) {
58640
+ frames.push({ offset, imageQualityStatus: replicateQualityOf(offset) });
58641
+ }
58642
+ }
58643
+ return frames;
58644
+ }
58645
+ function reverseBits(value, bits) {
58646
+ let reversed = 0;
58647
+ for (let bit = 0; bit < bits; bit++) {
58648
+ reversed = (reversed << 1) | ((value >> bit) & 1);
58649
+ }
58650
+ return reversed;
58651
+ }
58652
+ function gapAfterStage(index) {
58653
+ const level = index === 0 ? 0 : Math.floor(Math.log2(index)) + 1;
58654
+ return DECIMATE >> level;
58655
+ }
58656
+ const decimateStages = Array.from({ length: DECIMATE }, (_, index) => {
58657
+ const offset = reverseBits(index, OFFSET_BITS);
58658
+ const gap = gapAfterStage(index);
58659
+ return {
58660
+ id: `decimate${DECIMATE}At${offset}`,
58661
+ decimate: DECIMATE,
58662
+ offset,
58663
+ priority: 6 + index,
58664
+ requestType: _enums_index_js__rspack_import_0.RequestType.Thumbnail,
58665
+ retrieveType: 'default',
58666
+ nearbyFrames: gap > 1 ? nearbyFramesOfDecimation(gap) : undefined,
58667
+ };
58668
+ });
58669
+ const coarseInterleavedRetrieveStages = [
58670
+ {
58671
+ id: 'initialImages',
58672
+ positions: [0.5, -1],
58673
+ retrieveType: 'default',
58674
+ requestType: _enums_index_js__rspack_import_0.RequestType.Thumbnail,
58675
+ priority: 5,
58676
+ nearbyFrames: nearbyFramesOfDecimation(DECIMATE),
58677
+ },
58678
+ ...decimateStages,
58679
+ {
58680
+ id: 'errorRetrieve',
58681
+ },
58682
+ ];
58683
+ /* export default */ __webpack_exports__.A = (coarseInterleavedRetrieveStages);
58684
+
58685
+
56839
58686
  },
56840
58687
  93028(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
56841
58688
  "use strict";
@@ -57099,6 +58946,874 @@ __webpack_require__.d(__webpack_exports__, {
57099
58946
  });
57100
58947
 
57101
58948
 
58949
+ },
58950
+ 86998(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
58951
+ "use strict";
58952
+ /* import */ var _enums_ImageQualityStatus_js__rspack_import_0 = __webpack_require__(7330);
58953
+ /* import */ var _enums_VoxelDataSources_js__rspack_import_1 = __webpack_require__(2568);
58954
+ /* import */ var _enums_VoxelReductions_js__rspack_import_2 = __webpack_require__(33170);
58955
+ /* import */ var _enums_VoxelStatistics_js__rspack_import_3 = __webpack_require__(10475);
58956
+ /* import */ var _voxelGrid_index_js__rspack_import_4 = __webpack_require__(49617);
58957
+
58958
+
58959
+
58960
+
58961
+
58962
+ const MAX_COVERAGE_CELLS = 1 << 20;
58963
+ const MAX_COVERAGE_WORK = 1 << 23;
58964
+ function edgesOfAxis(boxes, region, axis) {
58965
+ const edges = new Set([region[axis][0], region[axis][1] + 1]);
58966
+ for (const box of boxes) {
58967
+ edges.add(box[axis][0]);
58968
+ edges.add(box[axis][1] + 1);
58969
+ }
58970
+ return [...edges].sort((a, b) => a - b);
58971
+ }
58972
+ function coverageOfRegion(deliveries, region) {
58973
+ const coverage = {
58974
+ covered: 0,
58975
+ lowest: undefined,
58976
+ highest: undefined,
58977
+ deliveries: 0,
58978
+ exact: true,
58979
+ };
58980
+ const clipped = [];
58981
+ for (const delivery of deliveries ?? []) {
58982
+ const bounds = (0,_voxelGrid_index_js__rspack_import_4.intersectBounds)(delivery.bounds, region);
58983
+ if ((0,_voxelGrid_index_js__rspack_import_4.volumeOfBounds)(bounds) > 0) {
58984
+ clipped.push({ bounds, quality: delivery.quality });
58985
+ coverage.deliveries++;
58986
+ }
58987
+ }
58988
+ if (clipped.length === 0) {
58989
+ return coverage;
58990
+ }
58991
+ const boxes = clipped.map((delivery) => delivery.bounds);
58992
+ const edges = [0, 1, 2].map((axis) => edgesOfAxis(boxes, region, axis));
58993
+ const counts = edges.map((axisEdges) => axisEdges.length - 1);
58994
+ const indexOfEdge = edges.map((axisEdges) => new Map(axisEdges.map((edge, index) => [edge, index])));
58995
+ const cellCount = counts[0] * counts[1] * counts[2];
58996
+ const spans = clipped.map((delivery) => ({
58997
+ from: [0, 1, 2].map((axis) => indexOfEdge[axis].get(delivery.bounds[axis][0])),
58998
+ to: [0, 1, 2].map((axis) => indexOfEdge[axis].get(delivery.bounds[axis][1] + 1)),
58999
+ }));
59000
+ const work = spans.reduce((total, { from, to }) => total + (to[0] - from[0]) * (to[1] - from[1]) * (to[2] - from[2]), 0);
59001
+ if (cellCount > MAX_COVERAGE_CELLS || work > MAX_COVERAGE_WORK) {
59002
+ for (const delivery of clipped) {
59003
+ const volume = (0,_voxelGrid_index_js__rspack_import_4.volumeOfBounds)(delivery.bounds);
59004
+ coverage.covered = Math.max(coverage.covered, volume);
59005
+ coverage.lowest = Math.min(coverage.lowest ?? delivery.quality, delivery.quality);
59006
+ coverage.highest = Math.max(coverage.highest ?? delivery.quality, delivery.quality);
59007
+ }
59008
+ coverage.exact = false;
59009
+ return coverage;
59010
+ }
59011
+ const cells = new Array(cellCount).fill(0);
59012
+ for (let index = 0; index < clipped.length; index++) {
59013
+ const delivery = clipped[index];
59014
+ const { from, to } = spans[index];
59015
+ for (let k = from[2]; k < to[2]; k++) {
59016
+ for (let j = from[1]; j < to[1]; j++) {
59017
+ for (let i = from[0]; i < to[0]; i++) {
59018
+ const cell = i + j * counts[0] + k * counts[0] * counts[1];
59019
+ if (delivery.quality > cells[cell]) {
59020
+ cells[cell] = delivery.quality;
59021
+ }
59022
+ }
59023
+ }
59024
+ }
59025
+ }
59026
+ for (let k = 0; k < counts[2]; k++) {
59027
+ for (let j = 0; j < counts[1]; j++) {
59028
+ for (let i = 0; i < counts[0]; i++) {
59029
+ const quality = cells[i + j * counts[0] + k * counts[0] * counts[1]];
59030
+ if (quality === 0) {
59031
+ continue;
59032
+ }
59033
+ coverage.covered +=
59034
+ (edges[0][i + 1] - edges[0][i]) *
59035
+ (edges[1][j + 1] - edges[1][j]) *
59036
+ (edges[2][k + 1] - edges[2][k]);
59037
+ coverage.lowest = Math.min(coverage.lowest ?? quality, quality);
59038
+ coverage.highest = Math.max(coverage.highest ?? quality, quality);
59039
+ }
59040
+ }
59041
+ }
59042
+ return coverage;
59043
+ }
59044
+ function countBelow(sorted, value) {
59045
+ let low = 0;
59046
+ let high = sorted.length;
59047
+ while (low < high) {
59048
+ const middle = (low + high) >> 1;
59049
+ if (sorted[middle] < value) {
59050
+ low = middle + 1;
59051
+ }
59052
+ else {
59053
+ high = middle;
59054
+ }
59055
+ }
59056
+ return low;
59057
+ }
59058
+ function firstRunEndingAtOrAfter(runs, k) {
59059
+ let low = 0;
59060
+ let high = runs.length;
59061
+ while (low < high) {
59062
+ const middle = (low + high) >> 1;
59063
+ if (runs[middle].end < k) {
59064
+ low = middle + 1;
59065
+ }
59066
+ else {
59067
+ high = middle;
59068
+ }
59069
+ }
59070
+ return low;
59071
+ }
59072
+ function addRun(runs, start, end, quality) {
59073
+ if (!(quality > 0)) {
59074
+ return;
59075
+ }
59076
+ const first = firstRunEndingAtOrAfter(runs, start - 1);
59077
+ let last = first;
59078
+ const pieces = [];
59079
+ let cursor = start;
59080
+ const push = (from, to, value) => {
59081
+ const previous = pieces[pieces.length - 1];
59082
+ if (previous && previous.end + 1 === from && previous.quality === value) {
59083
+ previous.end = to;
59084
+ }
59085
+ else {
59086
+ pieces.push({ start: from, end: to, quality: value });
59087
+ }
59088
+ };
59089
+ for (; last < runs.length && runs[last].start <= end + 1; last++) {
59090
+ const run = runs[last];
59091
+ if (run.start < start) {
59092
+ push(run.start, Math.min(run.end, start - 1), run.quality);
59093
+ }
59094
+ const from = Math.max(run.start, start);
59095
+ const to = Math.min(run.end, end);
59096
+ if (from <= to) {
59097
+ if (cursor < from) {
59098
+ push(cursor, from - 1, quality);
59099
+ }
59100
+ push(from, to, Math.max(run.quality, quality));
59101
+ cursor = to + 1;
59102
+ }
59103
+ if (run.end > end) {
59104
+ if (cursor <= end) {
59105
+ push(cursor, end, quality);
59106
+ cursor = end + 1;
59107
+ }
59108
+ push(Math.max(run.start, end + 1), run.end, run.quality);
59109
+ }
59110
+ }
59111
+ if (cursor <= end) {
59112
+ push(cursor, end, quality);
59113
+ }
59114
+ runs.splice(first, last - first, ...pieces);
59115
+ }
59116
+ function footprintKey(bounds) {
59117
+ return `${bounds[0][0]},${bounds[0][1]},${bounds[1][0]},${bounds[1][1]}`;
59118
+ }
59119
+ function addToCoverage(coverage, delivery) {
59120
+ const { bounds } = delivery;
59121
+ const key = footprintKey(bounds);
59122
+ let footprint = coverage.get(key);
59123
+ if (!footprint) {
59124
+ footprint = {
59125
+ i: [bounds[0][0], bounds[0][1]],
59126
+ j: [bounds[1][0], bounds[1][1]],
59127
+ members: new Set(),
59128
+ starts: [],
59129
+ ends: [],
59130
+ length: 0,
59131
+ runs: [],
59132
+ };
59133
+ coverage.set(key, footprint);
59134
+ }
59135
+ const [start, end] = bounds[2];
59136
+ footprint.members.add(delivery);
59137
+ footprint.starts.splice(countBelow(footprint.starts, start), 0, start);
59138
+ footprint.ends.splice(countBelow(footprint.ends, end), 0, end);
59139
+ footprint.length += Math.max(0, end - start + 1);
59140
+ if (footprint.runs) {
59141
+ addRun(footprint.runs, start, end, delivery.quality);
59142
+ }
59143
+ }
59144
+ function removeFromCoverage(coverage, delivery) {
59145
+ const key = footprintKey(delivery.bounds);
59146
+ const footprint = coverage.get(key);
59147
+ if (!footprint?.members.delete(delivery)) {
59148
+ return;
59149
+ }
59150
+ if (!footprint.members.size) {
59151
+ coverage.delete(key);
59152
+ return;
59153
+ }
59154
+ const [start, end] = delivery.bounds[2];
59155
+ footprint.starts.splice(countBelow(footprint.starts, start), 1);
59156
+ footprint.ends.splice(countBelow(footprint.ends, end), 1);
59157
+ footprint.length -= Math.max(0, end - start + 1);
59158
+ footprint.runs = undefined;
59159
+ }
59160
+ function raiseInCoverage(coverage, delivery) {
59161
+ const runs = coverage.get(footprintKey(delivery.bounds))?.runs;
59162
+ if (runs) {
59163
+ addRun(runs, delivery.bounds[2][0], delivery.bounds[2][1], delivery.quality);
59164
+ }
59165
+ }
59166
+ function coverageFromIncremental(coverage, region) {
59167
+ const result = {
59168
+ covered: 0,
59169
+ lowest: undefined,
59170
+ highest: undefined,
59171
+ deliveries: 0,
59172
+ exact: true,
59173
+ };
59174
+ if (coverage.size === 0 || (0,_voxelGrid_index_js__rspack_import_4.volumeOfBounds)(region) === 0) {
59175
+ return result;
59176
+ }
59177
+ if (coverage.size > 1) {
59178
+ return undefined;
59179
+ }
59180
+ const footprint = coverage.values().next().value;
59181
+ const width = Math.min(footprint.i[1], region[0][1]) -
59182
+ Math.max(footprint.i[0], region[0][0]) +
59183
+ 1;
59184
+ const height = Math.min(footprint.j[1], region[1][1]) -
59185
+ Math.max(footprint.j[0], region[1][0]) +
59186
+ 1;
59187
+ if (width <= 0 || height <= 0) {
59188
+ return result;
59189
+ }
59190
+ const [kStart, kEnd] = region[2];
59191
+ const met = countBelow(footprint.starts, kEnd + 1) - countBelow(footprint.ends, kStart);
59192
+ if (met <= 0) {
59193
+ return result;
59194
+ }
59195
+ const cells = 9 * (2 * met + 1);
59196
+ if (cells > MAX_COVERAGE_CELLS ||
59197
+ Math.min(footprint.length, met * cells) > MAX_COVERAGE_WORK) {
59198
+ return undefined;
59199
+ }
59200
+ if (!footprint.runs) {
59201
+ footprint.runs = [];
59202
+ for (const delivery of footprint.members) {
59203
+ addRun(footprint.runs, delivery.bounds[2][0], delivery.bounds[2][1], delivery.quality);
59204
+ }
59205
+ }
59206
+ const { runs } = footprint;
59207
+ let slices = 0;
59208
+ for (let index = firstRunEndingAtOrAfter(runs, kStart); index < runs.length && runs[index].start <= kEnd; index++) {
59209
+ const { start, end, quality } = runs[index];
59210
+ slices += Math.min(end, kEnd) - Math.max(start, kStart) + 1;
59211
+ result.lowest = Math.min(result.lowest ?? quality, quality);
59212
+ result.highest = Math.max(result.highest ?? quality, quality);
59213
+ }
59214
+ result.covered = slices * width * height;
59215
+ result.deliveries = met;
59216
+ return result;
59217
+ }
59218
+ function withStatus(record) {
59219
+ record.status = (0,_voxelGrid_index_js__rspack_import_4.imageQualityStatusOfRecord)(record);
59220
+ return record;
59221
+ }
59222
+ function voxelVolume(grid) {
59223
+ return grid.spacing[0] * grid.spacing[1] * grid.spacing[2];
59224
+ }
59225
+ function withinCeiling(grid, ceiling) {
59226
+ const tolerance = 1e-6;
59227
+ for (let axis = 0; axis < 3; axis++) {
59228
+ if (grid.spacing[axis] < ceiling[axis] - tolerance) {
59229
+ return false;
59230
+ }
59231
+ }
59232
+ return true;
59233
+ }
59234
+ const MAX_MAPPED_COVERAGES = 8;
59235
+ function exactGridKey(grid) {
59236
+ return [grid.dimensions, grid.spacing, grid.origin, grid.direction]
59237
+ .map((values) => Array.from(values).join(','))
59238
+ .join('|');
59239
+ }
59240
+ function mappedCopy(mapped, delivery) {
59241
+ const copy = {
59242
+ bounds: (0,_voxelGrid_index_js__rspack_import_4.mapBoundsBetweenGrids)(mapped.source, mapped.target, delivery.bounds),
59243
+ quality: delivery.quality,
59244
+ };
59245
+ mapped.copies.set(delivery, copy);
59246
+ return copy;
59247
+ }
59248
+ function boundsKey(bounds) {
59249
+ return `${bounds[0][0]},${bounds[0][1]},${bounds[1][0]},${bounds[1][1]},${bounds[2][0]},${bounds[2][1]}`;
59250
+ }
59251
+ function addToDeliveryIndex(index, delivery) {
59252
+ index.byBounds.set(boundsKey(delivery.bounds), delivery);
59253
+ for (let k = delivery.bounds[2][0]; k <= delivery.bounds[2][1]; k++) {
59254
+ let bucket = index.bySlice.get(k);
59255
+ if (!bucket) {
59256
+ bucket = new Set();
59257
+ index.bySlice.set(k, bucket);
59258
+ }
59259
+ bucket.add(delivery);
59260
+ }
59261
+ addToCoverage(index.coverage, delivery);
59262
+ for (const mapped of index.mapped.values()) {
59263
+ addToCoverage(mapped.coverage, mappedCopy(mapped, delivery));
59264
+ }
59265
+ }
59266
+ function removeFromDeliveryIndex(index, delivery) {
59267
+ index.byBounds.delete(boundsKey(delivery.bounds));
59268
+ for (let k = delivery.bounds[2][0]; k <= delivery.bounds[2][1]; k++) {
59269
+ index.bySlice.get(k)?.delete(delivery);
59270
+ }
59271
+ removeFromCoverage(index.coverage, delivery);
59272
+ for (const mapped of index.mapped.values()) {
59273
+ removeFromCoverage(mapped.coverage, mapped.copies.get(delivery));
59274
+ mapped.copies.delete(delivery);
59275
+ }
59276
+ }
59277
+ function raiseInDeliveryIndex(index, delivery) {
59278
+ raiseInCoverage(index.coverage, delivery);
59279
+ for (const mapped of index.mapped.values()) {
59280
+ const copy = mapped.copies.get(delivery);
59281
+ copy.quality = delivery.quality;
59282
+ raiseInCoverage(mapped.coverage, copy);
59283
+ }
59284
+ }
59285
+ function mappedCoverageOf(index, delivered, source, target) {
59286
+ const key = `${exactGridKey(source)}>${exactGridKey(target)}`;
59287
+ let mapped = index.mapped.get(key);
59288
+ if (!mapped) {
59289
+ if (index.mapped.size >= MAX_MAPPED_COVERAGES) {
59290
+ index.mapped.clear();
59291
+ }
59292
+ mapped = { source, target, coverage: new Map(), copies: new Map() };
59293
+ for (const delivery of delivered) {
59294
+ addToCoverage(mapped.coverage, mappedCopy(mapped, delivery));
59295
+ }
59296
+ index.mapped.set(key, mapped);
59297
+ }
59298
+ return mapped.coverage;
59299
+ }
59300
+ function buildDeliveryIndex(delivered) {
59301
+ const index = {
59302
+ byBounds: new Map(),
59303
+ bySlice: new Map(),
59304
+ coverage: new Map(),
59305
+ mapped: new Map(),
59306
+ };
59307
+ for (const delivery of delivered) {
59308
+ addToDeliveryIndex(index, delivery);
59309
+ }
59310
+ return index;
59311
+ }
59312
+ function boxReductionOf(statistic) {
59313
+ return ((0,_voxelGrid_index_js__rspack_import_4.requireVoxelStatistic)(statistic).boxReduction ?? _enums_VoxelReductions_js__rspack_import_2/* ["default"].BoxAverage */.A.BoxAverage);
59314
+ }
59315
+
59316
+ class CompositeVoxelManager {
59317
+ constructor({ primary, grid, statistic = _enums_VoxelStatistics_js__rspack_import_3/* ["default"].Average */.A.Average, quality, delivered, id, }) {
59318
+ this.representations = [];
59319
+ this.deliveryIndexes = new WeakMap();
59320
+ this.getAtIJK = (i, j, k) => {
59321
+ const value = this.primary.getAtIJK(i, j, k);
59322
+ if (value !== undefined && value !== null) {
59323
+ return value;
59324
+ }
59325
+ if (this.representations.length === 1) {
59326
+ return value;
59327
+ }
59328
+ return this.valueFromSources(this.coveringRepresentations().filter((representation) => representation !== this.primaryRepresentation), this.grid, [i, j, k]);
59329
+ };
59330
+ this.getAtIJKPoint = (point) => this.getAtIJK(point[0], point[1], point[2]);
59331
+ this.getAtIndex = (index) => this.getAtIJKPoint(this.toIJK(index));
59332
+ this.setAtIJK = (i, j, k, v) => this.primary.setAtIJK(i, j, k, v);
59333
+ this.setAtIJKPoint = (point, v) => this.primary.setAtIJKPoint(point, v);
59334
+ this.setAtIndex = (index, v) => this.primary.setAtIndex(index, v);
59335
+ this.forEach = (callback, options) => this.primary.forEach(callback, options);
59336
+ this.getSliceData = (args) => this.primary.getSliceData(args);
59337
+ this.getMiddleSliceData = () => this.primary.getMiddleSliceData();
59338
+ this.primary = primary;
59339
+ this.compositeId = id || `composite-${primary.id}`;
59340
+ this.primaryRepresentation = {
59341
+ grid,
59342
+ statistic,
59343
+ voxelManager: primary,
59344
+ quality,
59345
+ delivered,
59346
+ };
59347
+ this.representations.push(this.primaryRepresentation);
59348
+ }
59349
+ get grid() {
59350
+ return this.primaryRepresentation.grid;
59351
+ }
59352
+ getRepresentations() {
59353
+ return [...this.representations];
59354
+ }
59355
+ addRepresentation(representation) {
59356
+ const key = (0,_voxelGrid_index_js__rspack_import_4.voxelGridKey)(representation.grid, representation.statistic);
59357
+ const existing = this.representations.findIndex((candidate) => (0,_voxelGrid_index_js__rspack_import_4.voxelGridKey)(candidate.grid, candidate.statistic) === key);
59358
+ if (existing >= 0) {
59359
+ this.representations[existing] = representation;
59360
+ }
59361
+ else {
59362
+ this.representations.push(representation);
59363
+ }
59364
+ return representation;
59365
+ }
59366
+ getRepresentation(grid, statistic = _enums_VoxelStatistics_js__rspack_import_3/* ["default"].Average */.A.Average) {
59367
+ const key = (0,_voxelGrid_index_js__rspack_import_4.voxelGridKey)(grid, statistic);
59368
+ return this.representations.find((candidate) => (0,_voxelGrid_index_js__rspack_import_4.voxelGridKey)(candidate.grid, candidate.statistic) === key);
59369
+ }
59370
+ selectRepresentation({ region, statistic, ceiling, } = {}) {
59371
+ const candidates = this.candidatesFor(region, statistic);
59372
+ if (candidates.length === 0) {
59373
+ return undefined;
59374
+ }
59375
+ const atOrBelowCeiling = ceiling
59376
+ ? candidates.filter((candidate) => withinCeiling(candidate.grid, ceiling))
59377
+ : candidates;
59378
+ if (atOrBelowCeiling.length > 0) {
59379
+ return this.finest(atOrBelowCeiling, region);
59380
+ }
59381
+ return this.coarsest(candidates, region);
59382
+ }
59383
+ coveringRepresentations(region, statistic) {
59384
+ return this.candidatesFor(region, statistic).sort((a, b) => voxelVolume(a.grid) - voxelVolume(b.grid));
59385
+ }
59386
+ getGridQuality(grid, { statistic = _enums_VoxelStatistics_js__rspack_import_3/* ["default"].Average */.A.Average, region, } = {}) {
59387
+ const existing = this.getRepresentation(grid, statistic);
59388
+ if (existing) {
59389
+ return this.getRegionQuality(existing, region);
59390
+ }
59391
+ const source = this.sourceOfDerivation(this.grid, { statistic });
59392
+ if (!source) {
59393
+ return undefined;
59394
+ }
59395
+ const reducesAnAxis = !(0,_voxelGrid_index_js__rspack_import_4.voxelGridsEqual)(grid, source.grid);
59396
+ return this.getRegionQuality({
59397
+ grid,
59398
+ statistic,
59399
+ voxelManager: undefined,
59400
+ reduction: reducesAnAxis
59401
+ ? boxReductionOf(statistic)
59402
+ : _enums_VoxelReductions_js__rspack_import_2/* ["default"].None */.A.None,
59403
+ source: _enums_VoxelDataSources_js__rspack_import_1/* ["default"].ClientDerived */.A.ClientDerived,
59404
+ derivedFrom: {
59405
+ grid: source.grid,
59406
+ delivered: source.delivered,
59407
+ quality: source.quality,
59408
+ },
59409
+ }, region);
59410
+ }
59411
+ acceptData({ grid, voxelManager, imageIds, statistic = _enums_VoxelStatistics_js__rspack_import_3/* ["default"].Average */.A.Average, quality = _enums_ImageQualityStatus_js__rspack_import_0/* ["default"].FULL_RESOLUTION */.A.FULL_RESOLUTION, bounds, frameIndex, reduction, source, }) {
59412
+ const existing = this.getRepresentation(grid, statistic);
59413
+ const production = {
59414
+ reduction: reduction ?? existing?.reduction ?? _enums_VoxelReductions_js__rspack_import_2/* ["default"].None */.A.None,
59415
+ source: source ?? existing?.source ?? _enums_VoxelDataSources_js__rspack_import_1/* ["default"].DirectLoad */.A.DirectLoad,
59416
+ };
59417
+ const deliveredBounds = bounds ??
59418
+ (frameIndex === undefined ? undefined : (0,_voxelGrid_index_js__rspack_import_4.boundsOfFrame)(grid, frameIndex));
59419
+ if (!deliveredBounds) {
59420
+ return this.addRepresentation({
59421
+ grid,
59422
+ statistic,
59423
+ voxelManager: voxelManager ?? existing?.voxelManager,
59424
+ imageIds: imageIds ?? existing?.imageIds,
59425
+ quality,
59426
+ delivered: existing?.delivered,
59427
+ ...production,
59428
+ });
59429
+ }
59430
+ const representation = existing ??
59431
+ this.addRepresentation({
59432
+ grid,
59433
+ statistic,
59434
+ voxelManager,
59435
+ imageIds,
59436
+ delivered: [],
59437
+ ...production,
59438
+ });
59439
+ representation.reduction = production.reduction;
59440
+ representation.source = production.source;
59441
+ if (voxelManager && representation.voxelManager !== voxelManager) {
59442
+ representation.voxelManager = voxelManager;
59443
+ }
59444
+ if (imageIds) {
59445
+ representation.imageIds = imageIds;
59446
+ }
59447
+ this.setDeliveredQuality(representation, deliveredBounds, quality);
59448
+ return representation;
59449
+ }
59450
+ sourceOfDerivation(grid, { statistic }) {
59451
+ return (this.getRepresentation(grid, statistic) ||
59452
+ this.getRepresentation(grid, this.primaryRepresentation.statistic));
59453
+ }
59454
+ setDeliveredQuality(representation, bounds, quality) {
59455
+ if (!representation.delivered) {
59456
+ representation.delivered = [];
59457
+ }
59458
+ const { delivered } = representation;
59459
+ const index = this.deliveryIndexOf(delivered);
59460
+ const existing = index.byBounds.get(boundsKey(bounds));
59461
+ if (existing) {
59462
+ if (existing.quality >= quality) {
59463
+ return false;
59464
+ }
59465
+ existing.quality = quality;
59466
+ raiseInDeliveryIndex(index, existing);
59467
+ return true;
59468
+ }
59469
+ const containers = index.bySlice.get(bounds[2][0]);
59470
+ if (containers) {
59471
+ for (const delivery of containers) {
59472
+ if (delivery.quality >= quality &&
59473
+ (0,_voxelGrid_index_js__rspack_import_4.containsBounds)(delivery.bounds, bounds)) {
59474
+ return false;
59475
+ }
59476
+ }
59477
+ }
59478
+ const contained = new Set();
59479
+ for (let k = bounds[2][0]; k <= bounds[2][1]; k++) {
59480
+ const bucket = index.bySlice.get(k);
59481
+ if (!bucket) {
59482
+ continue;
59483
+ }
59484
+ for (const delivery of bucket) {
59485
+ if (delivery.quality <= quality &&
59486
+ (0,_voxelGrid_index_js__rspack_import_4.containsBounds)(bounds, delivery.bounds)) {
59487
+ contained.add(delivery);
59488
+ }
59489
+ }
59490
+ }
59491
+ if (contained.size) {
59492
+ for (const delivery of contained) {
59493
+ removeFromDeliveryIndex(index, delivery);
59494
+ }
59495
+ let write = 0;
59496
+ for (let read = 0; read < delivered.length; read++) {
59497
+ if (!contained.has(delivered[read])) {
59498
+ delivered[write++] = delivered[read];
59499
+ }
59500
+ }
59501
+ delivered.length = write;
59502
+ }
59503
+ const delivery = { bounds, quality };
59504
+ delivered.push(delivery);
59505
+ addToDeliveryIndex(index, delivery);
59506
+ return true;
59507
+ }
59508
+ deliveryIndexOf(delivered) {
59509
+ let index = this.deliveryIndexes.get(delivered);
59510
+ if (!index) {
59511
+ index = buildDeliveryIndex(delivered);
59512
+ this.deliveryIndexes.set(delivered, index);
59513
+ }
59514
+ return index;
59515
+ }
59516
+ coverageOf(delivered, region) {
59517
+ return ((delivered &&
59518
+ coverageFromIncremental(this.deliveryIndexOf(delivered).coverage, region)) ??
59519
+ coverageOfRegion(delivered, region));
59520
+ }
59521
+ getRegionQuality(representation, region) {
59522
+ const { grid } = representation;
59523
+ const target = region
59524
+ ? (0,_voxelGrid_index_js__rspack_import_4.intersectBounds)((0,_voxelGrid_index_js__rspack_import_4.mapBoundsBetweenGrids)(this.grid, grid, region), (0,_voxelGrid_index_js__rspack_import_4.boundsOfGrid)(grid))
59525
+ : (0,_voxelGrid_index_js__rspack_import_4.boundsOfGrid)(grid);
59526
+ const voxels = (0,_voxelGrid_index_js__rspack_import_4.volumeOfBounds)(target);
59527
+ const record = {
59528
+ grid,
59529
+ reduction: representation.reduction ?? _enums_VoxelReductions_js__rspack_import_2/* ["default"].None */.A.None,
59530
+ source: representation.source ?? _enums_VoxelDataSources_js__rspack_import_1/* ["default"].DirectLoad */.A.DirectLoad,
59531
+ lowest: undefined,
59532
+ highest: undefined,
59533
+ voxels,
59534
+ missing: voxels,
59535
+ deliveries: 0,
59536
+ exact: true,
59537
+ status: _enums_ImageQualityStatus_js__rspack_import_0/* ["default"].FAR_REPLICATE */.A.FAR_REPLICATE,
59538
+ };
59539
+ if (voxels === 0) {
59540
+ record.missing = 0;
59541
+ return withStatus(record);
59542
+ }
59543
+ if (representation.derivedFrom) {
59544
+ return withStatus(this.qualityOfDerived(representation, target, record));
59545
+ }
59546
+ const coverage = this.coverageOf(representation.delivered, target);
59547
+ let { covered } = coverage;
59548
+ record.deliveries = coverage.deliveries;
59549
+ record.lowest = coverage.lowest;
59550
+ record.highest = coverage.highest;
59551
+ record.exact = coverage.exact;
59552
+ if (covered < voxels && representation.quality !== undefined) {
59553
+ record.lowest = Math.min(record.lowest ?? representation.quality, representation.quality);
59554
+ record.highest = Math.max(record.highest ?? representation.quality, representation.quality);
59555
+ covered = voxels;
59556
+ }
59557
+ record.missing = voxels - covered;
59558
+ return withStatus(record);
59559
+ }
59560
+ fillGrid(grid, target, statistic = _enums_VoxelStatistics_js__rspack_import_3/* ["default"].Average */.A.Average) {
59561
+ const sources = this.coveringRepresentations(undefined, statistic);
59562
+ if (!sources.includes(this.primaryRepresentation)) {
59563
+ sources.unshift(this.primaryRepresentation);
59564
+ }
59565
+ let written = 0;
59566
+ for (let k = 0; k < grid.dimensions[2]; k++) {
59567
+ for (let j = 0; j < grid.dimensions[1]; j++) {
59568
+ for (let i = 0; i < grid.dimensions[0]; i++) {
59569
+ const value = this.valueFromSources(sources, grid, [i, j, k]);
59570
+ if (value === undefined) {
59571
+ continue;
59572
+ }
59573
+ target.setAtIJK(i, j, k, value);
59574
+ written++;
59575
+ }
59576
+ }
59577
+ }
59578
+ return written;
59579
+ }
59580
+ getQuality(selector = {}) {
59581
+ const selected = this.selectRepresentation(selector);
59582
+ return selected
59583
+ ? this.getRegionQuality(selected, selector.region)
59584
+ : undefined;
59585
+ }
59586
+ qualityOfDerived(representation, target, record) {
59587
+ const { grid, delivered, quality } = representation.derivedFrom;
59588
+ const sourceBounds = (0,_voxelGrid_index_js__rspack_import_4.intersectBounds)((0,_voxelGrid_index_js__rspack_import_4.mapBoundsBetweenGrids)(representation.grid, grid, target), (0,_voxelGrid_index_js__rspack_import_4.boundsOfGrid)(grid));
59589
+ const sourceVoxels = (0,_voxelGrid_index_js__rspack_import_4.volumeOfBounds)(sourceBounds);
59590
+ const coverage = this.coverageOf(delivered, sourceBounds);
59591
+ record.deliveries = coverage.deliveries;
59592
+ record.lowest = coverage.lowest;
59593
+ record.highest = coverage.highest;
59594
+ record.exact = coverage.exact;
59595
+ if (sourceVoxels === 0) {
59596
+ record.missing = record.voxels;
59597
+ return withStatus(record);
59598
+ }
59599
+ if (coverage.covered < sourceVoxels && quality !== undefined) {
59600
+ record.lowest = Math.min(record.lowest ?? quality, quality);
59601
+ record.highest = Math.max(record.highest ?? quality, quality);
59602
+ record.missing = 0;
59603
+ return withStatus(record);
59604
+ }
59605
+ const boxes = (delivered &&
59606
+ coverageFromIncremental(mappedCoverageOf(this.deliveryIndexOf(delivered), delivered, grid, representation.grid), target)) ??
59607
+ coverageOfRegion((delivered ?? []).map((delivery) => ({
59608
+ bounds: (0,_voxelGrid_index_js__rspack_import_4.mapBoundsBetweenGrids)(grid, representation.grid, delivery.bounds),
59609
+ quality: delivery.quality,
59610
+ })), target);
59611
+ record.missing = record.voxels - boxes.covered;
59612
+ record.exact = record.exact && boxes.exact;
59613
+ return withStatus(record);
59614
+ }
59615
+ candidatesFor(region, statistic) {
59616
+ return this.representations.filter((candidate) => {
59617
+ if (statistic) {
59618
+ if (candidate.statistic !== statistic) {
59619
+ return false;
59620
+ }
59621
+ }
59622
+ else if (!(0,_voxelGrid_index_js__rspack_import_4.isDefaultSelectionStatistic)(candidate.statistic)) {
59623
+ return false;
59624
+ }
59625
+ if (!region) {
59626
+ return true;
59627
+ }
59628
+ return (0,_voxelGrid_index_js__rspack_import_4.gridCoversRegion)(this.grid, region, candidate.grid);
59629
+ });
59630
+ }
59631
+ finest(representations, region) {
59632
+ return representations.reduce((best, candidate) => this.better(candidate, best, -1, region) ? candidate : best);
59633
+ }
59634
+ coarsest(representations, region) {
59635
+ return representations.reduce((best, candidate) => this.better(candidate, best, 1, region) ? candidate : best);
59636
+ }
59637
+ better(candidate, best, direction, region) {
59638
+ const difference = voxelVolume(candidate.grid) - voxelVolume(best.grid);
59639
+ if (Math.abs(difference) > 1e-9) {
59640
+ return Math.sign(difference) === direction;
59641
+ }
59642
+ const candidateQuality = this.getRegionQuality(candidate, region);
59643
+ const bestQuality = this.getRegionQuality(best, region);
59644
+ if (candidateQuality.missing !== bestQuality.missing) {
59645
+ return candidateQuality.missing < bestQuality.missing;
59646
+ }
59647
+ return (candidateQuality.lowest ?? 0) > (bestQuality.lowest ?? 0);
59648
+ }
59649
+ valueFromSources(sources, grid, ijk) {
59650
+ for (const source of sources) {
59651
+ const sourceIJK = (0,_voxelGrid_index_js__rspack_import_4.mapIndexToNearestVoxel)(grid, source.grid, ijk);
59652
+ const { dimensions } = source.voxelManager;
59653
+ if (sourceIJK[0] < 0 ||
59654
+ sourceIJK[1] < 0 ||
59655
+ sourceIJK[2] < 0 ||
59656
+ sourceIJK[0] >= dimensions[0] ||
59657
+ sourceIJK[1] >= dimensions[1] ||
59658
+ sourceIJK[2] >= dimensions[2]) {
59659
+ continue;
59660
+ }
59661
+ const value = source.voxelManager.getAtIJK(...sourceIJK);
59662
+ if (value !== undefined && value !== null) {
59663
+ return value;
59664
+ }
59665
+ }
59666
+ return undefined;
59667
+ }
59668
+ get id() {
59669
+ return this.compositeId;
59670
+ }
59671
+ get dimensions() {
59672
+ return this.primary.dimensions;
59673
+ }
59674
+ get numberOfComponents() {
59675
+ return this.primary.numberOfComponents;
59676
+ }
59677
+ get width() {
59678
+ return this.primary.width;
59679
+ }
59680
+ set width(width) {
59681
+ this.primary.width = width;
59682
+ }
59683
+ get frameSize() {
59684
+ return this.primary.frameSize;
59685
+ }
59686
+ set frameSize(frameSize) {
59687
+ this.primary.frameSize = frameSize;
59688
+ }
59689
+ get map() {
59690
+ return this.primary.map;
59691
+ }
59692
+ set map(map) {
59693
+ this.primary.map = map;
59694
+ }
59695
+ get sourceVoxelManager() {
59696
+ return this.primary.sourceVoxelManager;
59697
+ }
59698
+ set sourceVoxelManager(voxelManager) {
59699
+ this.primary.sourceVoxelManager = voxelManager;
59700
+ }
59701
+ get points() {
59702
+ return this.primary.points;
59703
+ }
59704
+ get modifiedSlices() {
59705
+ return this.primary.modifiedSlices;
59706
+ }
59707
+ get isInObject() {
59708
+ return this.primary.isInObject;
59709
+ }
59710
+ set isInObject(isInObject) {
59711
+ this.primary.isInObject = isInObject;
59712
+ }
59713
+ get sizeInBytes() {
59714
+ return this.primary.sizeInBytes;
59715
+ }
59716
+ get bytePerVoxel() {
59717
+ return this.primary.bytePerVoxel;
59718
+ }
59719
+ get _get() {
59720
+ return this.primary._get;
59721
+ }
59722
+ get _set() {
59723
+ return this.primary._set;
59724
+ }
59725
+ get _getConstructor() {
59726
+ return this.primary._getConstructor;
59727
+ }
59728
+ get _getScalarDataLength() {
59729
+ return this.primary._getScalarDataLength;
59730
+ }
59731
+ get _getScalarData() {
59732
+ return this.primary._getScalarData;
59733
+ }
59734
+ get _updateScalarData() {
59735
+ return this.primary._updateScalarData;
59736
+ }
59737
+ get _getSliceData() {
59738
+ return this.primary._getSliceData;
59739
+ }
59740
+ get getCompleteScalarDataArray() {
59741
+ return this.primary.getCompleteScalarDataArray;
59742
+ }
59743
+ get setCompleteScalarDataArray() {
59744
+ return this.primary.setCompleteScalarDataArray;
59745
+ }
59746
+ get invalidateCache() {
59747
+ return this.primary.invalidateCache;
59748
+ }
59749
+ get getRange() {
59750
+ return this.primary.getRange;
59751
+ }
59752
+ toIJK(index) {
59753
+ return this.primary.toIJK(index);
59754
+ }
59755
+ toIndex(ijk) {
59756
+ return this.primary.toIndex(ijk);
59757
+ }
59758
+ getDefaultBounds() {
59759
+ return this.primary.getDefaultBounds();
59760
+ }
59761
+ getBoundsIJK() {
59762
+ return this.primary.getBoundsIJK();
59763
+ }
59764
+ setBounds(bounds) {
59765
+ this.primary.setBounds(bounds);
59766
+ }
59767
+ clearBounds() {
59768
+ this.primary.clearBounds();
59769
+ }
59770
+ rleForEach(callback, options) {
59771
+ this.primary.rleForEach(callback, options);
59772
+ }
59773
+ getScalarData(storeScalarData) {
59774
+ return this.primary.getScalarData(storeScalarData);
59775
+ }
59776
+ setScalarData(newScalarData) {
59777
+ this.primary.setScalarData(newScalarData);
59778
+ }
59779
+ getWritableScalarData() {
59780
+ return this.primary.getWritableScalarData();
59781
+ }
59782
+ setFromScalarData(scalarData) {
59783
+ this.primary.setFromScalarData(scalarData);
59784
+ }
59785
+ getScalarDataLength() {
59786
+ return this.primary.getScalarDataLength();
59787
+ }
59788
+ getConstructor() {
59789
+ return this.primary.getConstructor();
59790
+ }
59791
+ getArrayOfModifiedSlices() {
59792
+ return this.primary.getArrayOfModifiedSlices();
59793
+ }
59794
+ resetModifiedSlices() {
59795
+ this.primary.resetModifiedSlices();
59796
+ }
59797
+ addPoint(point) {
59798
+ this.primary.addPoint(point);
59799
+ }
59800
+ getPoints() {
59801
+ return this.primary.getPoints();
59802
+ }
59803
+ getMinMax() {
59804
+ return this.primary.getMinMax();
59805
+ }
59806
+ clear() {
59807
+ this.primary.clear();
59808
+ }
59809
+ }
59810
+
59811
+
59812
+ __webpack_require__.d(__webpack_exports__, {
59813
+ Ay: () => (CompositeVoxelManager)
59814
+ });
59815
+
59816
+
57102
59817
  },
57103
59818
  90446(__unused_rspack___webpack_module__, __webpack_exports__) {
57104
59819
  "use strict";
@@ -59288,7 +62003,8 @@ function getVolumeSliceRangeInfo(viewport, volumeId, useSlabThickness = false) {
59288
62003
  const { focalPoint, viewPlaneNormal } = camera;
59289
62004
  const { spacingInNormalDirection, actorUID } = (0,_getTargetVolumeAndSpacingInNormalDir_js__rspack_import_1/* ["default"] */.A)(viewport, camera, volumeId, useSlabThickness);
59290
62005
  if (!actorUID) {
59291
- throw new Error(`Could not find image volume with id ${volumeId} in the viewport`);
62006
+ log.warn('No volume found in the viewport for the volumeId of', volumeId);
62007
+ return null;
59292
62008
  }
59293
62009
  const actorEntry = viewport.getActor(actorUID);
59294
62010
  if (!actorEntry) {
@@ -59327,7 +62043,11 @@ __webpack_require__.d(__webpack_exports__, {
59327
62043
  /* import */ var _getVolumeSliceRangeInfo_js__rspack_import_0 = __webpack_require__(18655);
59328
62044
 
59329
62045
  function getVolumeViewportScrollInfo(viewport, volumeId, useSlabThickness = false) {
59330
- const { sliceRange, spacingInNormalDirection, camera } = (0,_getVolumeSliceRangeInfo_js__rspack_import_0/* ["default"] */.A)(viewport, volumeId, useSlabThickness);
62046
+ const rangeInfo = (0,_getVolumeSliceRangeInfo_js__rspack_import_0/* ["default"] */.A)(viewport, volumeId, useSlabThickness);
62047
+ if (!rangeInfo) {
62048
+ return { numScrollSteps: 0, currentStepIndex: 0, sliceRangeInfo: null };
62049
+ }
62050
+ const { sliceRange, spacingInNormalDirection, camera } = rangeInfo;
59331
62051
  const { min, max, current } = sliceRange;
59332
62052
  const range = max - min;
59333
62053
  const numScrollSteps = range === 0 ? 0 : Math.round(range / spacingInNormalDirection);
@@ -59457,6 +62177,25 @@ __webpack_require__.d(__webpack_exports__, {
59457
62177
  });
59458
62178
 
59459
62179
 
62180
+ },
62181
+ 72372(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
62182
+ "use strict";
62183
+ /* import */ var gl_matrix__rspack_import_0 = __webpack_require__(50341);
62184
+
62185
+ function isAcquisitionPlaneNormal(imageVolume, viewPlaneNormal) {
62186
+ const { direction, dimensions, spacing } = imageVolume;
62187
+ const scanAxis = gl_matrix__rspack_import_0/* .vec3.fromValues */.eR.fA(direction[6], direction[7], direction[8]);
62188
+ const cos = Math.abs(gl_matrix__rspack_import_0/* .vec3.dot */.eR.Om(scanAxis, viewPlaneNormal));
62189
+ const sin = Math.sqrt(Math.max(0, 1 - cos * cos));
62190
+ const halfDiagonal = Math.hypot(dimensions[0] * spacing[0], dimensions[1] * spacing[1]) / 2;
62191
+ return sin * halfDiagonal < spacing[2] / 2;
62192
+ }
62193
+
62194
+ __webpack_require__.d(__webpack_exports__, {
62195
+ z: () => (isAcquisitionPlaneNormal)
62196
+ });
62197
+
62198
+
59460
62199
  },
59461
62200
  41227(__unused_rspack___webpack_module__, __webpack_exports__) {
59462
62201
  "use strict";
@@ -59971,6 +62710,212 @@ __webpack_require__.d(__webpack_exports__, {
59971
62710
  });
59972
62711
 
59973
62712
 
62713
+ },
62714
+ 9844(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
62715
+ "use strict";
62716
+ const SNAP = 1e-6;
62717
+ function snapToWhole(value) {
62718
+ const whole = Math.round(value);
62719
+ return Math.abs(value - whole) < SNAP ? whole : value;
62720
+ }
62721
+ function boxSpan(lo, hi) {
62722
+ const start = snapToWhole(lo);
62723
+ const stop = snapToWhole(hi);
62724
+ const first = Math.floor(start);
62725
+ const end = Math.max(first, Math.ceil(stop));
62726
+ if (end - first <= 1) {
62727
+ const weight = Math.max(0, stop - start);
62728
+ return { first, end, firstWeight: weight, lastWeight: weight };
62729
+ }
62730
+ return {
62731
+ first,
62732
+ end,
62733
+ firstWeight: first + 1 - start,
62734
+ lastWeight: stop - (end - 1),
62735
+ };
62736
+ }
62737
+ function weightInSpan(span, index) {
62738
+ if (index === span.first) {
62739
+ return span.firstWeight;
62740
+ }
62741
+ return index === span.end - 1 ? span.lastWeight : 1;
62742
+ }
62743
+ function spanOfBox(start, factor, stop, index) {
62744
+ const lo = start + index * factor;
62745
+ return boxSpan(lo, Math.min(lo + factor, stop));
62746
+ }
62747
+ function spansOfAxis(sourceSize, size, factor) {
62748
+ const spans = [];
62749
+ for (let target = 0; target < size; target++) {
62750
+ const lo = Math.min(target * factor, sourceSize);
62751
+ const hi = target === size - 1 ? sourceSize : Math.min(lo + factor, sourceSize);
62752
+ spans.push(boxSpan(lo, hi));
62753
+ }
62754
+ return spans;
62755
+ }
62756
+
62757
+
62758
+ __webpack_require__.d(__webpack_exports__, {
62759
+ Ac: () => (spansOfAxis),
62760
+ Oj: () => (weightInSpan),
62761
+ z1: () => (spanOfBox)
62762
+ });
62763
+
62764
+
62765
+ },
62766
+ 99190(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
62767
+ "use strict";
62768
+ /* import */ var _reducedDimensions_js__rspack_import_0 = __webpack_require__(8014);
62769
+
62770
+ function deriveBoxAverageGrid(source, reduction) {
62771
+ const factors = (0,_reducedDimensions_js__rspack_import_0/* .normalizedFactors */.qu)(reduction.factors);
62772
+ const sourceOffset = (reduction.sourceOffset ?? [0, 0, 0]);
62773
+ const sourceDimensions = (reduction.sourceDimensions ??
62774
+ source.dimensions);
62775
+ for (let axis = 0; axis < 3; axis++) {
62776
+ const offset = sourceOffset[axis];
62777
+ const size = sourceDimensions[axis];
62778
+ if (!Number.isInteger(offset) || offset < 0 || size < 1) {
62779
+ throw new Error(`deriveBoxAverageGrid: the region [${sourceOffset}] +[${sourceDimensions}] is not valid`);
62780
+ }
62781
+ if (offset + size > source.dimensions[axis]) {
62782
+ throw new Error(`deriveBoxAverageGrid: the region [${sourceOffset}] +[${sourceDimensions}] leaves the source grid [${source.dimensions}]`);
62783
+ }
62784
+ }
62785
+ const origin = [...source.origin];
62786
+ const spacing = [1, 1, 1];
62787
+ for (let axis = 0; axis < 3; axis++) {
62788
+ spacing[axis] = source.spacing[axis] * factors[axis];
62789
+ const shift = source.spacing[axis] * (sourceOffset[axis] + (factors[axis] - 1) / 2);
62790
+ origin[0] += source.direction[axis * 3] * shift;
62791
+ origin[1] += source.direction[axis * 3 + 1] * shift;
62792
+ origin[2] += source.direction[axis * 3 + 2] * shift;
62793
+ }
62794
+ return {
62795
+ origin,
62796
+ direction: Array.from(source.direction),
62797
+ spacing,
62798
+ dimensions: (0,_reducedDimensions_js__rspack_import_0/* .reducedDimensions */.on)(sourceDimensions, factors),
62799
+ };
62800
+ }
62801
+
62802
+
62803
+ __webpack_require__.d(__webpack_exports__, {
62804
+ y: () => (deriveBoxAverageGrid)
62805
+ });
62806
+
62807
+
62808
+ },
62809
+ 8014(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
62810
+ "use strict";
62811
+ function normalizedFactors(factors) {
62812
+ const normalized = [1, 1, 1];
62813
+ for (let axis = 0; axis < 3; axis++) {
62814
+ const factor = Number(factors?.[axis]);
62815
+ normalized[axis] = Number.isFinite(factor) ? Math.max(1, factor) : 1;
62816
+ }
62817
+ return normalized;
62818
+ }
62819
+ function reducedDimensions(sourceDimensions, factors) {
62820
+ const boxes = normalizedFactors(factors);
62821
+ const dimensions = [1, 1, 1];
62822
+ for (let axis = 0; axis < 3; axis++) {
62823
+ dimensions[axis] = Math.max(1, Math.ceil(sourceDimensions[axis] / boxes[axis] - 1e-6));
62824
+ }
62825
+ return dimensions;
62826
+ }
62827
+
62828
+
62829
+ __webpack_require__.d(__webpack_exports__, {
62830
+ on: () => (reducedDimensions),
62831
+ qu: () => (normalizedFactors)
62832
+ });
62833
+
62834
+
62835
+ },
62836
+ 37728(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
62837
+ "use strict";
62838
+ /* import */ var _reducedDimensions_js__rspack_import_0 = __webpack_require__(8014);
62839
+
62840
+ function resolveReduction(source, reduction) {
62841
+ const factors = (0,_reducedDimensions_js__rspack_import_0/* .normalizedFactors */.qu)(reduction.factors);
62842
+ const sourceOffset = (reduction.sourceOffset ?? [0, 0, 0]);
62843
+ const sourceDimensions = (reduction.sourceDimensions ??
62844
+ source.dimensions);
62845
+ return {
62846
+ factors,
62847
+ sourceOffset,
62848
+ sourceEnd: [
62849
+ sourceOffset[0] + sourceDimensions[0],
62850
+ sourceOffset[1] + sourceDimensions[1],
62851
+ sourceOffset[2] + sourceDimensions[2],
62852
+ ],
62853
+ dimensions: (0,_reducedDimensions_js__rspack_import_0/* .reducedDimensions */.on)(sourceDimensions, factors),
62854
+ };
62855
+ }
62856
+
62857
+ __webpack_require__.d(__webpack_exports__, {
62858
+ A: () => (resolveReduction)
62859
+ });
62860
+
62861
+
62862
+ },
62863
+ 70070(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
62864
+ "use strict";
62865
+ const KEY_PRECISION = 9;
62866
+ function keyNumber(value) {
62867
+ if (!Number.isFinite(value)) {
62868
+ return String(value);
62869
+ }
62870
+ const rounded = Number.parseFloat(value.toPrecision(KEY_PRECISION));
62871
+ return String(rounded === 0 ? 0 : rounded);
62872
+ }
62873
+ function keyNumbers(values) {
62874
+ const parts = [];
62875
+ for (let index = 0; index < values.length; index++) {
62876
+ parts.push(keyNumber(values[index]));
62877
+ }
62878
+ return parts.join(',');
62879
+ }
62880
+ function voxelGridKey(grid, statistic) {
62881
+ return [
62882
+ statistic,
62883
+ keyNumbers(grid.dimensions),
62884
+ keyNumbers(grid.spacing),
62885
+ keyNumbers(grid.origin),
62886
+ keyNumbers(grid.direction),
62887
+ ].join('|');
62888
+ }
62889
+ function voxelGridsEqual(gridA, gridB, tolerance = 1e-6) {
62890
+ if (!gridA || !gridB) {
62891
+ return gridA === gridB;
62892
+ }
62893
+ for (let axis = 0; axis < 3; axis++) {
62894
+ if (gridA.dimensions[axis] !== gridB.dimensions[axis]) {
62895
+ return false;
62896
+ }
62897
+ if (Math.abs(gridA.spacing[axis] - gridB.spacing[axis]) > tolerance) {
62898
+ return false;
62899
+ }
62900
+ if (Math.abs(gridA.origin[axis] - gridB.origin[axis]) > tolerance) {
62901
+ return false;
62902
+ }
62903
+ }
62904
+ for (let index = 0; index < 9; index++) {
62905
+ if (Math.abs(gridA.direction[index] - gridB.direction[index]) > tolerance) {
62906
+ return false;
62907
+ }
62908
+ }
62909
+ return true;
62910
+ }
62911
+
62912
+
62913
+ __webpack_require__.d(__webpack_exports__, {
62914
+ _I: () => (voxelGridsEqual),
62915
+ oC: () => (voxelGridKey)
62916
+ });
62917
+
62918
+
59974
62919
  },
59975
62920
  61761(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
59976
62921
  "use strict";
@@ -64886,7 +67831,7 @@ const moduleDefinitions = [
64886
67831
  },
64887
67832
  24671() {
64888
67833
  "use strict";
64889
- const version = '5.16.0';
67834
+ const version = '5.17.1';
64890
67835
 
64891
67836
 
64892
67837
  },
@@ -64989,7 +67934,7 @@ __webpack_require__.d(__webpack_exports__, {
64989
67934
  },
64990
67935
  88253() {
64991
67936
  "use strict";
64992
- const version = '5.16.0';
67937
+ const version = '5.17.1';
64993
67938
 
64994
67939
 
64995
67940
  },