@ohif/app 3.11.0-beta.99 → 3.11.0

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 (51) hide show
  1. package/dist/{2676.bundle.7e194265450db9aa1e98.js → 1402.bundle.e5306db9171c6c9793a7.js} +1379 -857
  2. package/dist/{9625.bundle.88dafbecfb596dade1a7.js → 1447.bundle.976ce9f69636f66a9eab.js} +2401 -2422
  3. package/dist/{147.bundle.c27839e06e2e8cabf9e1.js → 147.bundle.e22bae08eb10c0a51314.js} +42 -122
  4. package/dist/{1919.bundle.c53e597a4d2109ef7c97.js → 1919.bundle.ca1ffebd2ee775dc2d82.js} +6 -4
  5. package/dist/{2011.bundle.c44c0094525a51b528f4.js → 2011.bundle.12539f6bbbfc20a372e9.js} +2726 -197
  6. package/dist/{6216.bundle.48ff7813b6b3b8aba5f0.js → 2345.bundle.1fedf5750caf46ce99d9.js} +1 -35
  7. package/dist/{2701.bundle.d5c7ef6ec8b6cd9c2dfa.js → 2701.bundle.f2c7a5ab4a8b49d73bff.js} +9 -9
  8. package/dist/{2974.bundle.54d5903a8b29f1b09299.js → 2974.bundle.ec95e58b346dbe30a362.js} +2 -0
  9. package/dist/{7750.bundle.216dafe3c87d611928da.js → 319.bundle.45c1c250b562a3feefa5.js} +296 -62
  10. package/dist/{3658.bundle.046b575faed9e6bf1915.js → 3658.bundle.4b03e3bc783328aab18f.js} +2 -2
  11. package/dist/{9594.bundle.e623f61b984d7ff3b4b6.js → 4019.bundle.e07cc2a71b6e189a706a.js} +31 -157
  12. package/dist/{4113.bundle.46086f61126bf7100c6b.js → 4113.bundle.3b3fed48ad784ccda1a1.js} +268 -67
  13. package/dist/{414.bundle.443f391e019ece702e08.js → 414.bundle.fac8463232edcfda0b6c.js} +15 -15
  14. package/dist/{4202.bundle.aa4161a7b8cb7c691072.js → 4202.bundle.f804c72fb887b9543506.js} +1 -1
  15. package/dist/{4759.bundle.4da90b9346bb5e377ac6.js → 4759.bundle.8686abdd7bcf4aa7d107.js} +2 -0
  16. package/dist/{5349.bundle.be4b2d9a58412788944e.js → 5349.bundle.c117cc60ab5ff40eed14.js} +2 -2
  17. package/dist/{6972.bundle.0992b530f9691709f6d8.js → 557.bundle.a0344a04ae7a43642402.js} +5541 -5283
  18. package/dist/{5674.bundle.6c0d445cbd151b6e7aa1.js → 5674.bundle.4e40a906351477a2a193.js} +2 -0
  19. package/dist/{6201.bundle.a43859b8c8d3c89d73fe.js → 6201.bundle.5d7b8937f331f965d1aa.js} +4 -4
  20. package/dist/{6376.bundle.de4abf332424cba7513e.js → 6376.bundle.24e14fa9bf28c7c86e7c.js} +1 -1
  21. package/dist/{1943.bundle.3cf999579ec18e369ae6.js → 6991.bundle.08967b6f5698660e3a19.js} +67 -51
  22. package/dist/{7190.bundle.a35063abb9cb95986e67.js → 7190.bundle.4448c5a66a997bea24ca.js} +45 -8
  23. package/dist/{7197.bundle.c43fa621a7f16a4ea598.js → 7197.bundle.b8ce1b612ab1eff5d3ee.js} +5 -5
  24. package/dist/{810.bundle.0012733e3c8a87684485.js → 810.bundle.84fc54342c180b8a3023.js} +6 -6
  25. package/dist/{8228.bundle.2df7b5c0e4e0fdbb3654.js → 8228.bundle.ec3557eae81cafaed8c9.js} +2 -2
  26. package/dist/{85.bundle.c2855f98bbc7af94324a.js → 85.bundle.f9908f1f7350e5027d37.js} +3 -2
  27. package/dist/{8558.bundle.b69313ff865d69505f3f.js → 8558.bundle.ead200c0f2518d73739f.js} +3 -1
  28. package/dist/{860.bundle.f0d3efcceec48a1147ee.js → 860.bundle.f90055bfb2088bf17617.js} +24 -1
  29. package/dist/{8740.bundle.d0f554795adaecf0292c.js → 8740.bundle.9e567165a05c863b9698.js} +18 -5
  30. package/dist/{8815.bundle.85f43d0109e9e8eb7d2f.js → 8815.bundle.9999a630034893a74508.js} +32 -10
  31. package/dist/{934.bundle.f60a5cfd492b9b2f80d7.js → 934.bundle.e620a43102a8abf8a1e3.js} +4 -2
  32. package/dist/{963.bundle.5a8404d29251b83344c9.js → 963.bundle.b2434897acfb3e8abee5.js} +29 -9
  33. package/dist/{1443.bundle.405ff549a88a585906f3.js → 9732.bundle.91cb05748bef4e4f67c2.js} +883 -1731
  34. package/dist/{9560.bundle.203976e64c9a0202e247.js → 9856.bundle.c34e4165e91ef095aa9f.js} +5853 -5649
  35. package/dist/{9862.bundle.11d2a0f6528e9e916e25.js → 9862.bundle.e404cb5f0e762fbf6a03.js} +2 -14
  36. package/dist/{5886.bundle.181e673d6d5a9333039a.js → 9892.bundle.364aba175ce50baeb46c.js} +35397 -32968
  37. package/dist/app-config.js +8 -0
  38. package/dist/{app.bundle.4c2206d03a480f25fa24.js → app.bundle.804c5a4cd283acda540d.js} +2239 -1468
  39. package/dist/{compute.bundle.06ee8311038e4ac2d34d.js → compute.bundle.a1c8365c4732e8b82ca3.js} +3 -3
  40. package/dist/index.html +1 -1
  41. package/dist/{interpolation.bundle.6b3b374f2888d3744e61.js → interpolation.bundle.488206d0a2c4fa1dd6c5.js} +1 -1
  42. package/dist/{polySeg.bundle.d8a36b40716862d016de.js → polySeg.bundle.02258624e0ec30e9934c.js} +3 -3
  43. package/dist/sw.js +1 -1
  44. package/package.json +22 -22
  45. /package/dist/{1459.bundle.ce20cf6141ce43861cb6.js → 1459.bundle.163c80965265cae11781.js} +0 -0
  46. /package/dist/{1807.bundle.b29feec5110c55747364.js → 1807.bundle.d79c83317de38e4cffbd.js} +0 -0
  47. /package/dist/{213.bundle.5f47c7726bac8015c955.js → 213.bundle.f8b1fd7851428f0fa02f.js} +0 -0
  48. /package/dist/{2424.bundle.efc13d194c408554908e.js → 2424.bundle.7469c5960e905196f646.js} +0 -0
  49. /package/dist/{6027.bundle.80487e243df9ca540b1e.js → 6027.bundle.ab73f6c39c04c7662744.js} +0 -0
  50. /package/dist/{7431.bundle.503dc3262479de76225b.js → 7431.bundle.494b080a8141ef60067a.js} +0 -0
  51. /package/dist/{7639.bundle.d266780fbc9fe5a0053f.js → 7639.bundle.664fc584f04ca34a4bf1.js} +0 -0
@@ -1,4 +1,4 @@
1
- (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[1443],{
1
+ (globalThis["webpackChunk"] = globalThis["webpackChunk"] || []).push([[9732],{
2
2
 
3
3
  /***/ 3293:
4
4
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
@@ -439,7 +439,121 @@ module.exports = iota
439
439
 
440
440
  /***/ }),
441
441
 
442
- /***/ 34279:
442
+ /***/ 49892:
443
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
444
+
445
+ "use strict";
446
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
447
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
448
+ /* harmony export */ });
449
+ var ToolModes;
450
+ (function (ToolModes) {
451
+ ToolModes["Active"] = "Active";
452
+ ToolModes["Passive"] = "Passive";
453
+ ToolModes["Enabled"] = "Enabled";
454
+ ToolModes["Disabled"] = "Disabled";
455
+ })(ToolModes || (ToolModes = {}));
456
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ToolModes);
457
+
458
+
459
+ /***/ }),
460
+
461
+ /***/ 66452:
462
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
463
+
464
+ "use strict";
465
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
466
+ /* harmony export */ i: () => (/* binding */ MouseBindings),
467
+ /* harmony export */ q: () => (/* binding */ KeyboardBindings)
468
+ /* harmony export */ });
469
+ var MouseBindings;
470
+ (function (MouseBindings) {
471
+ MouseBindings[MouseBindings["Primary"] = 1] = "Primary";
472
+ MouseBindings[MouseBindings["Secondary"] = 2] = "Secondary";
473
+ MouseBindings[MouseBindings["Primary_And_Secondary"] = 3] = "Primary_And_Secondary";
474
+ MouseBindings[MouseBindings["Auxiliary"] = 4] = "Auxiliary";
475
+ MouseBindings[MouseBindings["Primary_And_Auxiliary"] = 5] = "Primary_And_Auxiliary";
476
+ MouseBindings[MouseBindings["Secondary_And_Auxiliary"] = 6] = "Secondary_And_Auxiliary";
477
+ MouseBindings[MouseBindings["Primary_And_Secondary_And_Auxiliary"] = 7] = "Primary_And_Secondary_And_Auxiliary";
478
+ MouseBindings[MouseBindings["Fourth_Button"] = 8] = "Fourth_Button";
479
+ MouseBindings[MouseBindings["Fifth_Button"] = 16] = "Fifth_Button";
480
+ MouseBindings[MouseBindings["Wheel"] = 524288] = "Wheel";
481
+ MouseBindings[MouseBindings["Wheel_Primary"] = 524289] = "Wheel_Primary";
482
+ })(MouseBindings || (MouseBindings = {}));
483
+ var KeyboardBindings;
484
+ (function (KeyboardBindings) {
485
+ KeyboardBindings[KeyboardBindings["Shift"] = 16] = "Shift";
486
+ KeyboardBindings[KeyboardBindings["Ctrl"] = 17] = "Ctrl";
487
+ KeyboardBindings[KeyboardBindings["Alt"] = 18] = "Alt";
488
+ KeyboardBindings[KeyboardBindings["Meta"] = 91] = "Meta";
489
+ KeyboardBindings[KeyboardBindings["ShiftCtrl"] = 1617] = "ShiftCtrl";
490
+ KeyboardBindings[KeyboardBindings["ShiftAlt"] = 1618] = "ShiftAlt";
491
+ KeyboardBindings[KeyboardBindings["ShiftMeta"] = 1691] = "ShiftMeta";
492
+ KeyboardBindings[KeyboardBindings["CtrlAlt"] = 1718] = "CtrlAlt";
493
+ KeyboardBindings[KeyboardBindings["CtrlMeta"] = 1791] = "CtrlMeta";
494
+ KeyboardBindings[KeyboardBindings["AltMeta"] = 1891] = "AltMeta";
495
+ })(KeyboardBindings || (KeyboardBindings = {}));
496
+
497
+
498
+
499
+ /***/ }),
500
+
501
+ /***/ 75183:
502
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
503
+
504
+ "use strict";
505
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
506
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
507
+ /* harmony export */ });
508
+ var ChangeTypes;
509
+ (function (ChangeTypes) {
510
+ ChangeTypes["Interaction"] = "Interaction";
511
+ ChangeTypes["HandlesUpdated"] = "HandlesUpdated";
512
+ ChangeTypes["StatsUpdated"] = "StatsUpdated";
513
+ ChangeTypes["InitialSetup"] = "InitialSetup";
514
+ ChangeTypes["Completed"] = "Completed";
515
+ ChangeTypes["InterpolationUpdated"] = "InterpolationUpdated";
516
+ ChangeTypes["History"] = "History";
517
+ ChangeTypes["MetadataReferenceModified"] = "MetadataReferenceModified";
518
+ ChangeTypes["LabelChange"] = "LabelChange";
519
+ })(ChangeTypes || (ChangeTypes = {}));
520
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ChangeTypes);
521
+
522
+
523
+ /***/ }),
524
+
525
+ /***/ 84093:
526
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
527
+
528
+ "use strict";
529
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
530
+ /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
531
+ /* harmony export */ });
532
+ var StrategyCallbacks;
533
+ (function (StrategyCallbacks) {
534
+ StrategyCallbacks["OnInteractionStart"] = "onInteractionStart";
535
+ StrategyCallbacks["OnInteractionEnd"] = "onInteractionEnd";
536
+ StrategyCallbacks["Preview"] = "preview";
537
+ StrategyCallbacks["RejectPreview"] = "rejectPreview";
538
+ StrategyCallbacks["AcceptPreview"] = "acceptPreview";
539
+ StrategyCallbacks["Fill"] = "fill";
540
+ StrategyCallbacks["Interpolate"] = "interpolate";
541
+ StrategyCallbacks["StrategyFunction"] = "strategyFunction";
542
+ StrategyCallbacks["CreateIsInThreshold"] = "createIsInThreshold";
543
+ StrategyCallbacks["Initialize"] = "initialize";
544
+ StrategyCallbacks["INTERNAL_setValue"] = "setValue";
545
+ StrategyCallbacks["AddPreview"] = "addPreview";
546
+ StrategyCallbacks["ComputeInnerCircleRadius"] = "computeInnerCircleRadius";
547
+ StrategyCallbacks["GetStatistics"] = "getStatistics";
548
+ StrategyCallbacks["EnsureImageVolumeFor3DManipulation"] = "ensureImageVolumeFor3DManipulation";
549
+ StrategyCallbacks["EnsureSegmentationVolumeFor3DManipulation"] = "ensureSegmentationVolumeFor3DManipulation";
550
+ })(StrategyCallbacks || (StrategyCallbacks = {}));
551
+ /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (StrategyCallbacks);
552
+
553
+
554
+ /***/ }),
555
+
556
+ /***/ 92740:
443
557
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
444
558
 
445
559
  "use strict";
@@ -447,6 +561,7 @@ module.exports = iota
447
561
  // EXPORTS
448
562
  __webpack_require__.d(__webpack_exports__, {
449
563
  fX: () => (/* reexport */ enums_namespaceObject),
564
+ W6: () => (/* reexport */ NO_IMAGE_ID),
450
565
  X6: () => (/* reexport */ adaptersPMAP),
451
566
  f_: () => (/* reexport */ adaptersRT),
452
567
  ql: () => (/* reexport */ adaptersSEG),
@@ -454,8 +569,6 @@ __webpack_require__.d(__webpack_exports__, {
454
569
  _$: () => (/* reexport */ helpers_namespaceObject)
455
570
  });
456
571
 
457
- // UNUSED EXPORTS: NO_IMAGE_ID
458
-
459
572
  // NAMESPACE OBJECT: ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/Cornerstone/Segmentation.js
460
573
  var Segmentation_namespaceObject = {};
461
574
  __webpack_require__.r(Segmentation_namespaceObject);
@@ -508,7 +621,7 @@ __webpack_require__.d(helpers_namespaceObject, {
508
621
  // EXTERNAL MODULE: ../../../node_modules/dcmjs/build/dcmjs.es.js
509
622
  var dcmjs_es = __webpack_require__(5842);
510
623
  ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/helpers/toArray.js
511
- const toArray = x => Array.isArray(x) ? x : [x];
624
+ const toArray = x => Array.isArray(x) ? x : x !== undefined ? [x] : [];
512
625
 
513
626
 
514
627
 
@@ -523,12 +636,15 @@ const codeMeaningEquals = codeMeaningName => {
523
636
 
524
637
  // EXTERNAL MODULE: ../../../node_modules/buffer/index.js
525
638
  var node_modules_buffer = __webpack_require__(81429);
639
+ // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/index.js + 1 modules
640
+ var esm = __webpack_require__(15327);
526
641
  ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/Cornerstone/MeasurementReport.js
527
642
 
528
643
 
529
644
 
530
645
 
531
646
 
647
+
532
648
  const {
533
649
  TID1500,
534
650
  addAccessors
@@ -574,8 +690,9 @@ const codeValueMatch = (group, code, oldCode) => {
574
690
  function getTID300ContentItem(tool, ReferencedSOPSequence, adapterClass) {
575
691
  const args = adapterClass.getTID300RepresentationArguments(tool);
576
692
  args.ReferencedSOPSequence = ReferencedSOPSequence;
577
- const TID300Measurement = new adapterClass.TID300Representation(args);
578
- return TID300Measurement;
693
+ args.ReferencedFrameOfReferenceUID = args.use3DSpatialCoordinates ? tool.metadata.FrameOfReferenceUID : null;
694
+ const tid300Measurement = new adapterClass.TID300Representation(args);
695
+ return tid300Measurement;
579
696
  }
580
697
  function getMeasurementGroup(toolType, toolData, ReferencedSOPSequence) {
581
698
  const toolTypeData = toolData[toolType];
@@ -586,10 +703,10 @@ function getMeasurementGroup(toolType, toolData, ReferencedSOPSequence) {
586
703
 
587
704
  // Loop through the array of tool instances
588
705
  // for this tool
589
- const Measurements = toolTypeData.data.map(tool => {
706
+ const measurements = toolTypeData.data.map(tool => {
590
707
  return getTID300ContentItem(tool, ReferencedSOPSequence, toolClass);
591
708
  });
592
- return new TID1501MeasurementGroup(Measurements);
709
+ return new TID1501MeasurementGroup(measurements);
593
710
  }
594
711
  class MeasurementReport {
595
712
  static getSetupMeasurementData(MeasurementGroup) {
@@ -687,7 +804,7 @@ class MeasurementReport {
687
804
  });
688
805
  allMeasurementGroups = allMeasurementGroups.concat(measurementGroups);
689
806
  });
690
- const MeasurementReport = new TID1500MeasurementReport({
807
+ const tid1500MeasurementReport = new TID1500MeasurementReport({
691
808
  TID1501MeasurementGroups: allMeasurementGroups
692
809
  }, options);
693
810
 
@@ -729,7 +846,7 @@ class MeasurementReport {
729
846
  derivationSourceDataset._meta = _meta;
730
847
  derivationSourceDataset._vrMap = _vrMap;
731
848
  const report = new StructuredReport([derivationSourceDataset]);
732
- const contentItem = MeasurementReport.contentItem(derivationSourceDataset);
849
+ const contentItem = tid1500MeasurementReport.contentItem(derivationSourceDataset);
733
850
 
734
851
  // Merge the derived dataset with the content from the Measurement Report
735
852
  report.dataset = Object.assign(report.dataset, contentItem);
@@ -971,6 +1088,7 @@ MeasurementReport.registerTool(FreehandRoi);
971
1088
 
972
1089
 
973
1090
 
1091
+
974
1092
  const {
975
1093
  Bidirectional: TID300Bidirectional
976
1094
  } = dcmjs_es/* utilities */.BF.TID300;
@@ -3208,6 +3326,9 @@ function getImageIdOfSourceImageBySourceImageSequence(SourceImageSequence, sopUI
3208
3326
  if (ReferencedFrameNumber !== undefined) {
3209
3327
  if (baseImageId.includes("frames/")) {
3210
3328
  return baseImageId.replace(/frames\/\d+/, `frames/${ReferencedFrameNumber}`);
3329
+ } else if (baseImageId.includes("dicomfile:")) {
3330
+ // dicomfile base 1, despite having frame=
3331
+ return baseImageId.replace(/frame=\d+/, `frame=${ReferencedFrameNumber}`);
3211
3332
  } else if (baseImageId.includes("frame=")) {
3212
3333
  return baseImageId.replace(/frame=\d+/, `frame=${ReferencedFrameNumber - 1}`);
3213
3334
  } else {
@@ -3785,8 +3906,6 @@ const CornerstonePMAP = {
3785
3906
 
3786
3907
 
3787
3908
 
3788
- // EXTERNAL MODULE: ../../../node_modules/@cornerstonejs/core/dist/esm/index.js + 1 modules
3789
- var esm = __webpack_require__(15327);
3790
3909
  ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/Cornerstone3D/cornerstone3DTag.js
3791
3910
  var CORNERSTONE_3D_TAG = "Cornerstone3DTools@^0.1.0";
3792
3911
 
@@ -3832,6 +3951,60 @@ function copySeriesTags(src) {
3832
3951
 
3833
3952
 
3834
3953
 
3954
+ ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/helpers/scoordToWorld.js
3955
+
3956
+
3957
+ const {
3958
+ imageToWorldCoords
3959
+ } = esm.utilities;
3960
+ function scoordToWorld(_ref, scoord) {
3961
+ let {
3962
+ is3DMeasurement,
3963
+ referencedImageId
3964
+ } = _ref;
3965
+ const worldCoords = [];
3966
+ if (is3DMeasurement) {
3967
+ const {
3968
+ GraphicData
3969
+ } = scoord;
3970
+ for (let i = 0; i < GraphicData.length; i += 3) {
3971
+ const point = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
3972
+ worldCoords.push(point);
3973
+ }
3974
+ } else {
3975
+ const {
3976
+ GraphicData
3977
+ } = scoord;
3978
+ for (let i = 0; i < GraphicData.length; i += 2) {
3979
+ const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
3980
+ worldCoords.push(point);
3981
+ }
3982
+ }
3983
+ return worldCoords;
3984
+ }
3985
+
3986
+
3987
+
3988
+ ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/helpers/toPoint3.js
3989
+ function toPoint3(flatPoints) {
3990
+ const points = [];
3991
+ if (!flatPoints?.length) {
3992
+ return points;
3993
+ }
3994
+ const {
3995
+ length: n
3996
+ } = flatPoints;
3997
+ if (n % 3 !== 0) {
3998
+ throw new Error(`Points array should be divisible by 3 for SCOORD3D, but contents are: ${JSON.stringify(flatPoints)} of length ${n}`);
3999
+ }
4000
+ for (let i = 0; i < n; i += 3) {
4001
+ points.push([flatPoints[i], flatPoints[i + 1], flatPoints[i + 2]]);
4002
+ }
4003
+ return points;
4004
+ }
4005
+
4006
+
4007
+
3835
4008
  ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/Cornerstone3D/CodingScheme.js
3836
4009
  // This is a custom coding scheme defined to store some annotations from Cornerstone.
3837
4010
  // Note: CodeMeaning is VR type LO, which means we only actually support 64 characters
@@ -3851,6 +4024,156 @@ const CodingScheme = {
3851
4024
 
3852
4025
  ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/Cornerstone3D/constants/index.js
3853
4026
  const NO_IMAGE_ID = "none";
4027
+ const CS3D_DESIGNATOR = "99CS3D";
4028
+ const TEXT_ANNOTATION_POSITION = {
4029
+ schemeDesignator: CS3D_DESIGNATOR,
4030
+ meaning: "Text Annotation Position",
4031
+ value: "TextPosition"
4032
+ };
4033
+ const COMMENT_CODE = {
4034
+ schemeDesignator: "DCM",
4035
+ meaning: "Comment",
4036
+ value: "121106"
4037
+ };
4038
+
4039
+
4040
+
4041
+ ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/helpers/toScoordType.js
4042
+
4043
+
4044
+ const {
4045
+ worldToImageCoords: globalWorldToImageCoords
4046
+ } = esm.utilities;
4047
+ let useWorldToImageCoords = globalWorldToImageCoords;
4048
+ function toScoord(_ref, point) {
4049
+ let {
4050
+ is3DMeasurement,
4051
+ referencedImageId
4052
+ } = _ref;
4053
+ if (is3DMeasurement) {
4054
+ return {
4055
+ x: point[0],
4056
+ y: point[1],
4057
+ z: point[2]
4058
+ };
4059
+ }
4060
+ const point2 = useWorldToImageCoords(referencedImageId, point);
4061
+ return {
4062
+ x: point2[0],
4063
+ y: point2[1]
4064
+ };
4065
+ }
4066
+ function toScoords(scoordArgs, points) {
4067
+ return points.map(point => toScoord(scoordArgs, point));
4068
+ }
4069
+ function setWorldToImageCoords() {
4070
+ let worldToImage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : globalWorldToImageCoords;
4071
+ useWorldToImageCoords = worldToImage;
4072
+ }
4073
+
4074
+
4075
+
4076
+ ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/Cornerstone3D/LabelData.js
4077
+
4078
+
4079
+
4080
+
4081
+
4082
+
4083
+ const {
4084
+ sr: {
4085
+ valueTypes,
4086
+ coding
4087
+ }
4088
+ } = dcmjs_es/* default */.Ay;
4089
+ const LabelData_CORNERSTONEFREETEXT = "CORNERSTONEFREETEXT";
4090
+ class LabelData {
4091
+ constructor(tid300Item, annotation) {
4092
+ this.tid300Item = tid300Item;
4093
+ this.annotation = annotation;
4094
+ this.ReferencedSOPSequence = tid300Item.ReferencedSOPSequence;
4095
+ }
4096
+ contentItem() {
4097
+ const contentEntries = this.tid300Item.contentItem();
4098
+ const {
4099
+ label,
4100
+ handles
4101
+ } = this.annotation.data;
4102
+ if (label) {
4103
+ contentEntries.push(this.createQualitativeLabel(label));
4104
+ this.filterCornerstoneFreeText(contentEntries);
4105
+ }
4106
+ if (handles?.textBox?.hasMoved) {
4107
+ contentEntries.push(this.createQualitativeLabelPosition(this.annotation));
4108
+ }
4109
+ return contentEntries;
4110
+ }
4111
+ filterCornerstoneFreeText(contentEntries) {
4112
+ for (let i = 0; i < contentEntries.length; i++) {
4113
+ const group = contentEntries[i];
4114
+ if (!group.ConceptCodeSequence) {
4115
+ continue;
4116
+ }
4117
+ const csLabel = group.ConceptCodeSequence.find(item => item.CodeValue === LabelData_CORNERSTONEFREETEXT);
4118
+ if (csLabel !== -1) {
4119
+ group.ConceptCodeSequence.splice(csLabel, 1);
4120
+ if (group.ConceptCodeSequence.length === 0) {
4121
+ contentEntries.splice(i, 1);
4122
+ }
4123
+ return;
4124
+ }
4125
+ }
4126
+ }
4127
+ createQualitativeLabel(label) {
4128
+ const relationshipType = valueTypes.RelationshipTypes.CONTAINS;
4129
+ return new valueTypes.TextContentItem({
4130
+ name: new coding.CodedConcept(COMMENT_CODE),
4131
+ relationshipType,
4132
+ value: label
4133
+ });
4134
+ }
4135
+ createQualitativeLabelPosition(annotation) {
4136
+ const {
4137
+ textBox
4138
+ } = annotation.data.handles;
4139
+ const {
4140
+ referencedImageId,
4141
+ FrameOfReferenceUID: frameOfReferenceUID
4142
+ } = annotation.metadata;
4143
+ const is3DMeasurement = !referencedImageId;
4144
+ const {
4145
+ worldPosition
4146
+ } = textBox;
4147
+ const {
4148
+ x,
4149
+ y,
4150
+ z
4151
+ } = toScoord({
4152
+ is3DMeasurement,
4153
+ referencedImageId
4154
+ }, worldPosition);
4155
+ const graphicType = valueTypes.GraphicTypes.POINT;
4156
+ const relationshipType = valueTypes.RelationshipTypes.CONTAINS;
4157
+ const name = new coding.CodedConcept(TEXT_ANNOTATION_POSITION);
4158
+ if (is3DMeasurement) {
4159
+ const graphicData = [x, y, z];
4160
+ return new valueTypes.Scoord3DContentItem({
4161
+ name,
4162
+ relationshipType,
4163
+ graphicType,
4164
+ frameOfReferenceUID,
4165
+ graphicData
4166
+ });
4167
+ }
4168
+ const graphicData = [x, y];
4169
+ return new valueTypes.ScoordContentItem({
4170
+ name,
4171
+ relationshipType,
4172
+ graphicType,
4173
+ graphicData
4174
+ });
4175
+ }
4176
+ }
3854
4177
 
3855
4178
 
3856
4179
 
@@ -3866,6 +4189,9 @@ const NO_IMAGE_ID = "none";
3866
4189
 
3867
4190
 
3868
4191
 
4192
+
4193
+
4194
+
3869
4195
  var _MeasurementReport;
3870
4196
  const {
3871
4197
  TID1500: MeasurementReport_TID1500,
@@ -3888,6 +4214,14 @@ const MeasurementReport_FINDING = {
3888
4214
  CodingSchemeDesignator: "DCM",
3889
4215
  CodeValue: "121071"
3890
4216
  };
4217
+ const COMMENT = {
4218
+ CodingSchemeDesignator: COMMENT_CODE.schemeDesignator,
4219
+ CodeValue: COMMENT_CODE.value
4220
+ };
4221
+ const COMMENT_POSITION = {
4222
+ CodingSchemeDesignator: TEXT_ANNOTATION_POSITION.schemeDesignator,
4223
+ CodeValue: TEXT_ANNOTATION_POSITION.value
4224
+ };
3891
4225
  const MeasurementReport_FINDING_SITE = {
3892
4226
  CodingSchemeDesignator: "SCT",
3893
4227
  CodeValue: "363698007"
@@ -3897,28 +4231,36 @@ const MeasurementReport_FINDING_SITE_OLD = {
3897
4231
  CodeValue: "G-C0E3"
3898
4232
  };
3899
4233
  class MeasurementReport_MeasurementReport {
3900
- static getTID300ContentItem(tool, ReferencedSOPSequence, toolClass, worldToImageCoords) {
3901
- const args = toolClass.getTID300RepresentationArguments(tool, worldToImageCoords);
4234
+ static getTID300ContentItem(tool, ReferencedSOPSequence, toolClass, is3DMeasurement) {
4235
+ const args = toolClass.getTID300RepresentationArguments(tool, is3DMeasurement);
3902
4236
  args.ReferencedSOPSequence = ReferencedSOPSequence;
3903
- const TID300Measurement = new toolClass.TID300Representation(args);
3904
- return TID300Measurement;
4237
+ if (args.use3DSpatialCoordinates) {
4238
+ args.ReferencedFrameOfReferenceUID = tool.metadata.FrameOfReferenceUID;
4239
+ }
4240
+ const tid300Measurement = new toolClass.TID300Representation(args);
4241
+ const labelMeasurement = new LabelData(tid300Measurement, tool);
4242
+ return labelMeasurement;
3905
4243
  }
3906
- static getMeasurementGroup(toolType, toolData, ReferencedSOPSequence, worldToImageCoords) {
4244
+ static getMeasurementGroup(toolType, toolData, ReferencedSOPSequence, is3DMeasurement) {
3907
4245
  const toolTypeData = toolData[toolType];
3908
4246
  const toolClass = this.measurementAdapterByToolType.get(toolType);
3909
4247
  if (!toolTypeData || !toolTypeData.data || !toolTypeData.data.length || !toolClass) {
3910
4248
  return;
3911
4249
  }
3912
4250
  const Measurements = toolTypeData.data.map(tool => {
3913
- return this.getTID300ContentItem(tool, ReferencedSOPSequence, toolClass, worldToImageCoords);
4251
+ return this.getTID300ContentItem(tool, ReferencedSOPSequence, toolClass, is3DMeasurement);
3914
4252
  });
3915
4253
  return new MeasurementReport_TID1501MeasurementGroup(Measurements);
3916
4254
  }
3917
4255
  static getCornerstoneLabelFromDefaultState(defaultState) {
3918
4256
  const {
3919
4257
  findingSites = [],
3920
- finding
4258
+ finding,
4259
+ commentGroup
3921
4260
  } = defaultState;
4261
+ if (commentGroup?.TextValue) {
4262
+ return commentGroup.TextValue;
4263
+ }
3922
4264
  const cornersoneFreeTextCodingValue = CodingScheme.codeValues.CORNERSTONEFREETEXT;
3923
4265
  const freeTextLabel = findingSites.find(fs => fs.CodeValue === cornersoneFreeTextCodingValue);
3924
4266
  if (freeTextLabel) {
@@ -3967,21 +4309,32 @@ class MeasurementReport_MeasurementReport {
3967
4309
  } = ReferencedSOPSequence;
3968
4310
  const referencedImageId = sopInstanceUIDToImageIdMap[ReferencedSOPInstanceUID];
3969
4311
  const imagePlaneModule = metadata.get("imagePlaneModule", referencedImageId);
4312
+ const annotationUID = MeasurementReport_DicomMetaDictionary.uid();
3970
4313
  return {
3971
4314
  SCOORDGroup,
3972
4315
  ReferencedSOPSequence,
3973
4316
  ReferencedSOPInstanceUID,
3974
4317
  ReferencedFrameNumber,
4318
+ referencedImageId,
3975
4319
  state: {
3976
4320
  description: undefined,
3977
4321
  sopInstanceUid: ReferencedSOPInstanceUID,
3978
4322
  annotation: {
3979
- annotationUID: MeasurementReport_DicomMetaDictionary.uid(),
4323
+ data: {
4324
+ annotationUID,
4325
+ cachedStats: {},
4326
+ handles: {
4327
+ activeHandleIndex: 0,
4328
+ textBox: {
4329
+ hasMoved: false
4330
+ }
4331
+ }
4332
+ },
4333
+ annotationUID,
3980
4334
  metadata: {
3981
4335
  toolName: toolType,
3982
4336
  referencedImageId,
3983
- FrameOfReferenceUID: imagePlaneModule.frameOfReferenceUID,
3984
- label: ""
4337
+ FrameOfReferenceUID: imagePlaneModule.frameOfReferenceUID
3985
4338
  }
3986
4339
  }
3987
4340
  }
@@ -3992,21 +4345,33 @@ class MeasurementReport_MeasurementReport {
3992
4345
  SCOORD3DGroup,
3993
4346
  toolType
3994
4347
  } = _ref2;
3995
- return {
4348
+ const annotationUID = MeasurementReport_DicomMetaDictionary.uid();
4349
+ const toolData = {
3996
4350
  SCOORD3DGroup,
3997
4351
  FrameOfReferenceUID: SCOORD3DGroup.ReferencedFrameOfReferenceUID,
3998
4352
  state: {
3999
4353
  description: undefined,
4000
4354
  annotation: {
4001
- annotationUID: MeasurementReport_DicomMetaDictionary.uid(),
4355
+ annotationUID,
4356
+ data: {
4357
+ annotationUID,
4358
+ cachedStats: {},
4359
+ handles: {
4360
+ activeHandleIndex: 0,
4361
+ textBox: {
4362
+ hasMoved: false
4363
+ }
4364
+ }
4365
+ },
4002
4366
  metadata: {
4003
4367
  toolName: toolType,
4004
- FrameOfReferenceUID: SCOORD3DGroup.ReferencedFrameOfReferenceUID,
4005
- label: ""
4368
+ FrameOfReferenceUID: SCOORD3DGroup.ReferencedFrameOfReferenceUID
4006
4369
  }
4007
4370
  }
4008
4371
  }
4009
4372
  };
4373
+ esm.utilities.updatePlaneRestriction(toPoint3(SCOORD3DGroup.GraphicData), toolData.state.annotation.metadata);
4374
+ return toolData;
4010
4375
  }
4011
4376
  static getSpatialCoordinatesState(_ref3) {
4012
4377
  let {
@@ -4015,23 +4380,22 @@ class MeasurementReport_MeasurementReport {
4015
4380
  metadata,
4016
4381
  toolType
4017
4382
  } = _ref3;
4018
- const SCOORDGroup = toArray(NUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD");
4019
- const SCOORD3DGroup = toArray(NUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD3D");
4020
- if (SCOORDGroup) {
4021
- return this.processSCOORDGroup({
4022
- SCOORDGroup,
4023
- toolType,
4024
- metadata,
4025
- sopInstanceUIDToImageIdMap
4026
- });
4027
- } else if (SCOORD3DGroup) {
4028
- return this.processSCOORD3DGroup({
4029
- SCOORD3DGroup,
4030
- toolType
4031
- });
4032
- } else {
4383
+ const contentSequenceArr = toArray(NUMGroup.ContentSequence);
4384
+ const SCOORDGroup = contentSequenceArr.find(group => group.ValueType === "SCOORD");
4385
+ const SCOORD3DGroup = contentSequenceArr.find(group => group.ValueType === "SCOORD3D");
4386
+ const result = SCOORD3DGroup && this.processSCOORD3DGroup({
4387
+ SCOORD3DGroup,
4388
+ toolType
4389
+ }) || SCOORDGroup && this.processSCOORDGroup({
4390
+ SCOORDGroup,
4391
+ toolType,
4392
+ metadata,
4393
+ sopInstanceUIDToImageIdMap
4394
+ });
4395
+ if (!result) {
4033
4396
  throw new Error("No spatial coordinates group found.");
4034
4397
  }
4398
+ return result;
4035
4399
  }
4036
4400
  static processSpatialCoordinatesGroup(_ref4) {
4037
4401
  let {
@@ -4040,6 +4404,8 @@ class MeasurementReport_MeasurementReport {
4040
4404
  metadata,
4041
4405
  findingGroup,
4042
4406
  findingSiteGroups,
4407
+ commentGroup,
4408
+ commentPositionGroup,
4043
4409
  toolType
4044
4410
  } = _ref4;
4045
4411
  const {
@@ -4049,7 +4415,9 @@ class MeasurementReport_MeasurementReport {
4049
4415
  ReferencedSOPInstanceUID,
4050
4416
  ReferencedFrameNumber,
4051
4417
  SCOORD3DGroup,
4052
- FrameOfReferenceUID
4418
+ FrameOfReferenceUID,
4419
+ referencedImageId,
4420
+ textBoxPosition
4053
4421
  } = this.getSpatialCoordinatesState({
4054
4422
  NUMGroup,
4055
4423
  sopInstanceUIDToImageIdMap,
@@ -4060,21 +4428,35 @@ class MeasurementReport_MeasurementReport {
4060
4428
  const findingSites = findingSiteGroups.map(fsg => {
4061
4429
  return MeasurementReport_addAccessors(fsg.ConceptCodeSequence);
4062
4430
  });
4063
- const defaultState = {
4064
- ...state,
4065
- finding,
4066
- findingSites
4067
- };
4068
- if (defaultState.finding) {
4069
- defaultState.description = defaultState.finding.CodeMeaning;
4431
+ if (commentPositionGroup) {
4432
+ state.commentPositionGroup = commentPositionGroup;
4433
+ const textBoxCoords = scoordToWorld({
4434
+ is3DMeasurement: !referencedImageId,
4435
+ referencedImageId
4436
+ }, commentPositionGroup);
4437
+ state.annotation.data.handles.textBox = {
4438
+ hasMoved: true,
4439
+ worldPosition: textBoxCoords[0]
4440
+ };
4070
4441
  }
4071
- defaultState.annotation.metadata.label = MeasurementReport_MeasurementReport.getCornerstoneLabelFromDefaultState(defaultState);
4442
+ state.finding = finding;
4443
+ state.findingSites = findingSites;
4444
+ state.commentGroup = commentGroup;
4445
+ state.commentPositionGroup = commentPositionGroup;
4446
+ if (finding) {
4447
+ state.description = finding.CodeMeaning;
4448
+ }
4449
+ state.annotation.data.label = this.getCornerstoneLabelFromDefaultState(state);
4072
4450
  return {
4073
- defaultState,
4451
+ defaultState: state,
4452
+ state,
4074
4453
  NUMGroup,
4454
+ scoord: SCOORD3DGroup || SCOORDGroup,
4075
4455
  SCOORDGroup,
4076
4456
  ReferencedSOPSequence,
4077
4457
  ReferencedSOPInstanceUID,
4458
+ referencedImageId,
4459
+ textBoxPosition,
4078
4460
  ReferencedFrameNumber,
4079
4461
  SCOORD3DGroup,
4080
4462
  FrameOfReferenceUID
@@ -4086,16 +4468,39 @@ class MeasurementReport_MeasurementReport {
4086
4468
  } = MeasurementGroup;
4087
4469
  const contentSequenceArr = toArray(ContentSequence);
4088
4470
  const findingGroup = contentSequenceArr.find(group => this.codeValueMatch(group, MeasurementReport_FINDING));
4471
+ const commentGroup = contentSequenceArr.find(group => this.codeValueMatch(group, COMMENT));
4472
+ const commentPositionGroup = contentSequenceArr.find(group => this.codeValueMatch(group, COMMENT_POSITION));
4089
4473
  const findingSiteGroups = contentSequenceArr.filter(group => this.codeValueMatch(group, MeasurementReport_FINDING_SITE, MeasurementReport_FINDING_SITE_OLD)) || [];
4090
- const NUMGroup = contentSequenceArr.find(group => group.ValueType === "NUM");
4091
- return this.processSpatialCoordinatesGroup({
4474
+ const NUMGroup = contentSequenceArr.find(group => group.ValueType === "NUM") || {
4475
+ ContentSequence: contentSequenceArr.filter(group => group.ValueType === "SCOORD" || group.ValueType === "SCOORD3D")
4476
+ };
4477
+ const spatialGroup = this.processSpatialCoordinatesGroup({
4092
4478
  NUMGroup,
4093
4479
  sopInstanceUIDToImageIdMap,
4094
4480
  metadata,
4095
4481
  findingGroup,
4096
4482
  findingSiteGroups,
4483
+ commentGroup,
4484
+ commentPositionGroup,
4097
4485
  toolType
4098
4486
  });
4487
+ const {
4488
+ referencedImageId
4489
+ } = spatialGroup.state.annotation.metadata;
4490
+ const is3DMeasurement = !!spatialGroup.SCOORD3DGroup;
4491
+ const scoordArgs = {
4492
+ referencedImageId,
4493
+ is3DMeasurement
4494
+ };
4495
+ const scoord = spatialGroup.SCOORD3DGroup || spatialGroup.SCOORDGroup;
4496
+ const worldCoords = scoordToWorld(scoordArgs, scoord);
4497
+ return {
4498
+ ...spatialGroup,
4499
+ is3DMeasurement,
4500
+ scoordArgs,
4501
+ scoord,
4502
+ worldCoords
4503
+ };
4099
4504
  }
4100
4505
  static generateReferencedSOPSequence(_ref5) {
4101
4506
  let {
@@ -4143,10 +4548,13 @@ class MeasurementReport_MeasurementReport {
4143
4548
  const referenceToolData = toolData?.[toolTypes?.[0]]?.data?.[0];
4144
4549
  const volumeId = referenceToolData?.metadata?.volumeId;
4145
4550
  const volume = esm.cache.getVolume(volumeId);
4551
+ if (!volume) {
4552
+ throw new Error(`No volume found for ${volumeId}`);
4553
+ }
4146
4554
  const imageId = volume.imageIds[0];
4147
4555
  return imageId;
4148
4556
  }
4149
- static generateReport(toolState, metadataProvider, worldToImageCoords, options) {
4557
+ static generateReport(toolState, metadataProvider, options) {
4150
4558
  let allMeasurementGroups = [];
4151
4559
  const sopInstanceUIDsToSeriesInstanceUIDMap = {};
4152
4560
  const derivationSourceDatasets = [];
@@ -4155,6 +4563,7 @@ class MeasurementReport_MeasurementReport {
4155
4563
  Object.keys(toolState).forEach(imageId => {
4156
4564
  const toolData = toolState[imageId];
4157
4565
  const toolTypes = Object.keys(toolData);
4566
+ const is3DMeasurement = imageId === NO_IMAGE_ID;
4158
4567
  const ReferencedSOPSequence = this.generateReferencedSOPSequence({
4159
4568
  toolData,
4160
4569
  toolTypes,
@@ -4163,12 +4572,12 @@ class MeasurementReport_MeasurementReport {
4163
4572
  sopInstanceUIDsToSeriesInstanceUIDMap,
4164
4573
  derivationSourceDatasets
4165
4574
  });
4166
- if (imageId === NO_IMAGE_ID) {
4575
+ if (is3DMeasurement) {
4167
4576
  is3DSR = true;
4168
4577
  }
4169
4578
  const measurementGroups = [];
4170
4579
  toolTypes.forEach(toolType => {
4171
- const group = this.getMeasurementGroup(toolType, toolData, ReferencedSOPSequence, worldToImageCoords);
4580
+ const group = this.getMeasurementGroup(toolType, toolData, ReferencedSOPSequence, is3DMeasurement);
4172
4581
  if (group) {
4173
4582
  measurementGroups.push(group);
4174
4583
  }
@@ -4188,10 +4597,13 @@ class MeasurementReport_MeasurementReport {
4188
4597
  report.SpecificCharacterSet = "ISO_IR 192";
4189
4598
  if (is3DSR) {
4190
4599
  report.dataset.SOPClassUID = MeasurementReport_DicomMetaDictionary.sopClassUIDsByName.Comprehensive3DSR;
4600
+ if (!report.dataset.SOPClassUID) {
4601
+ throw new Error(`NO sop class defined for Comprehensive3DSR in ${JSON.stringify(MeasurementReport_DicomMetaDictionary.sopClassUIDsByName)}`);
4602
+ }
4191
4603
  }
4192
4604
  return report;
4193
4605
  }
4194
- static generateToolState(dataset, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata, hooks) {
4606
+ static generateToolState(dataset, sopInstanceUIDToImageIdMap, metadata, hooks) {
4195
4607
  if (dataset.ContentTemplateSequence.TemplateIdentifier !== "1500") {
4196
4608
  throw new Error("This package can currently only interpret DICOM SR TID 1500");
4197
4609
  }
@@ -4211,9 +4623,9 @@ class MeasurementReport_MeasurementReport {
4211
4623
  } = trackingIdentifierGroup;
4212
4624
  const trackingUniqueIdentifierGroup = measurementGroupContentSequence.find(contentItem => contentItem.ConceptNameCodeSequence.CodeMeaning === TRACKING_UNIQUE_IDENTIFIER);
4213
4625
  const trackingUniqueIdentifierValue = trackingUniqueIdentifierGroup?.UID;
4214
- const toolAdapter = hooks?.getToolClass?.(measurementGroup, dataset, this.measurementAdapterByToolType) || this.getAdapterForTrackingIdentifier(trackingIdentifierValue);
4626
+ const toolAdapter = hooks?.getToolClass?.(measurementGroup, dataset, this.measurementAdapterByToolType) || this.getAdapterForTrackingIdentifier(trackingIdentifierValue) || this.getAdapterForCodeType(measurementGroup);
4215
4627
  if (toolAdapter) {
4216
- const measurement = toolAdapter.getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata, trackingIdentifierValue);
4628
+ const measurement = toolAdapter.getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, metadata, trackingIdentifierValue);
4217
4629
  measurement.TrackingUniqueIdentifier = trackingUniqueIdentifierValue;
4218
4630
  console.log(`=== ${toolAdapter.toolType} ===`);
4219
4631
  console.log(measurement);
@@ -4260,10 +4672,40 @@ class MeasurementReport_MeasurementReport {
4260
4672
  }
4261
4673
  }
4262
4674
  }
4675
+ static getAdapterForCodeType(measurementGroup) {
4676
+ for (const adapter of this.measurementAdapterByTrackingIdentifier.values()) {
4677
+ if (adapter.isValidMeasurement(measurementGroup)) {
4678
+ return adapter;
4679
+ }
4680
+ }
4681
+ }
4682
+ static registerAdapterTypes(adapter) {
4683
+ for (var _len2 = arguments.length, types = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
4684
+ types[_key2 - 1] = arguments[_key2];
4685
+ }
4686
+ for (const type of types) {
4687
+ if (!this.measurementAdaptersByType.has(type)) {
4688
+ this.measurementAdaptersByType.set(type, []);
4689
+ }
4690
+ const adapters = this.measurementAdaptersByType.get(type);
4691
+ if (adapters.indexOf(adapter) === -1) {
4692
+ adapters.push(adapter);
4693
+ }
4694
+ }
4695
+ }
4696
+ static getAdaptersForTypes(graphicCode, graphicType, pointCount) {
4697
+ const adapters = [];
4698
+ appendList(adapters, this.measurementAdaptersByType.get(`${graphicCode}-${graphicType}-${pointCount}`));
4699
+ appendList(adapters, this.measurementAdaptersByType.get(`${graphicCode}-${graphicType}`));
4700
+ appendList(adapters, this.measurementAdaptersByType.get(graphicCode));
4701
+ appendList(adapters, this.measurementAdaptersByType.get(graphicType));
4702
+ return adapters;
4703
+ }
4263
4704
  }
4264
4705
  _MeasurementReport = MeasurementReport_MeasurementReport;
4265
4706
  _MeasurementReport.CORNERSTONE_3D_TAG = CORNERSTONE_3D_TAG;
4266
4707
  _MeasurementReport.measurementAdapterByToolType = new Map();
4708
+ _MeasurementReport.measurementAdaptersByType = new Map();
4267
4709
  _MeasurementReport.measurementAdapterByTrackingIdentifier = new Map();
4268
4710
  _MeasurementReport.codeValueMatch = (group, code, oldCode) => {
4269
4711
  const {
@@ -4286,6 +4728,12 @@ _MeasurementReport.generateDerivationSourceDataset = instance => {
4286
4728
  ...seriesTags
4287
4729
  };
4288
4730
  };
4731
+ function appendList(list, appendList) {
4732
+ if (!appendList?.length) {
4733
+ return;
4734
+ }
4735
+ list.push(...appendList);
4736
+ }
4289
4737
 
4290
4738
 
4291
4739
 
@@ -4293,7 +4741,55 @@ _MeasurementReport.generateDerivationSourceDataset = instance => {
4293
4741
 
4294
4742
 
4295
4743
 
4744
+
4745
+
4746
+
4747
+
4296
4748
  class BaseAdapter3D {
4749
+ static registerType() {
4750
+ let code = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
4751
+ let type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
4752
+ let count = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
4753
+ let key = code;
4754
+ if (type) {
4755
+ key = `${key}${key.length ? "-" : ""}${type}`;
4756
+ }
4757
+ if (count) {
4758
+ key = `${key}${key.length ? "-" : ""}${count}`;
4759
+ }
4760
+ MeasurementReport_MeasurementReport.registerAdapterTypes(this, key);
4761
+ }
4762
+ static getPointsCount(graphicItem) {
4763
+ const is3DMeasurement = graphicItem.ValueType === "SCOORD3D";
4764
+ const pointSize = is3DMeasurement ? 3 : 2;
4765
+ return graphicItem.GraphicData.length / pointSize;
4766
+ }
4767
+ static getGraphicItems(measurementGroup, filter) {
4768
+ const items = measurementGroup.ContentSequence.filter(group => group.ValueType === "SCOORD" || group.ValueType === "SCOORD3D");
4769
+ return filter ? items.filter(filter) : items;
4770
+ }
4771
+ static getGraphicItem(measurementGroup) {
4772
+ let offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
4773
+ let type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4774
+ const items = this.getGraphicItems(measurementGroup, type && (group => group.ValueType === type));
4775
+ return items[offset];
4776
+ }
4777
+ static getGraphicCode(graphicItem) {
4778
+ const {
4779
+ ConceptNameCodeSequence: conceptNameItem
4780
+ } = graphicItem;
4781
+ const {
4782
+ CodeValue: graphicValue,
4783
+ CodingSchemeDesignator: graphicDesignator
4784
+ } = conceptNameItem;
4785
+ return `${graphicDesignator}:${graphicValue}`;
4786
+ }
4787
+ static getGraphicType(graphicItem) {
4788
+ return graphicItem.GraphicType;
4789
+ }
4790
+ static isValidMeasurement(_measurementGroup) {
4791
+ return false;
4792
+ }
4297
4793
  static init(toolType, representation, options) {
4298
4794
  this.toolType = toolType;
4299
4795
  if (BaseAdapter3D.toolType) {
@@ -4332,7 +4828,7 @@ class BaseAdapter3D {
4332
4828
  }
4333
4829
  return trackingIdentifier.startsWith(this.trackingIdentifierTextValue);
4334
4830
  }
4335
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, _imageToWorldCoords, metadata, trackingIdentifier) {
4831
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, trackingIdentifier) {
4336
4832
  const {
4337
4833
  defaultState: state,
4338
4834
  ReferencedFrameNumber
@@ -4344,9 +4840,9 @@ class BaseAdapter3D {
4344
4840
  };
4345
4841
  return state;
4346
4842
  }
4347
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
4843
+ static getTID300RepresentationArguments(tool) {
4844
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4348
4845
  const {
4349
- data,
4350
4846
  metadata
4351
4847
  } = tool;
4352
4848
  const {
@@ -4356,52 +4852,19 @@ class BaseAdapter3D {
4356
4852
  const {
4357
4853
  referencedImageId
4358
4854
  } = metadata;
4359
- if (!referencedImageId) {
4360
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
4361
- }
4362
- const {
4363
- handles: {
4364
- points = []
4365
- }
4366
- } = data;
4367
- const pointsImage = points.map(point => {
4368
- const pointImage = worldToImageCoords(referencedImageId, point);
4369
- return {
4370
- x: pointImage[0],
4371
- y: pointImage[1]
4372
- };
4373
- });
4855
+ const scoordProps = {
4856
+ is3DMeasurement,
4857
+ referencedImageId
4858
+ };
4859
+ const pointsImage = toScoords(scoordProps, tool.data.handles.points);
4374
4860
  const tidArguments = {
4375
4861
  points: pointsImage,
4376
4862
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
4377
4863
  findingSites: findingSites || [],
4378
- finding
4379
- };
4380
- return tidArguments;
4381
- }
4382
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
4383
- const {
4384
- data,
4385
4864
  finding,
4386
- findingSites
4387
- } = tool;
4388
- const {
4389
- handles: {
4390
- points = []
4391
- }
4392
- } = data;
4393
- const point = points[0];
4394
- const pointXYZ = {
4395
- x: point[0],
4396
- y: point[1],
4397
- z: point[2]
4398
- };
4399
- return {
4400
- points: [pointXYZ],
4401
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
4402
- findingSites: findingSites || [],
4403
- finding
4865
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null
4404
4866
  };
4867
+ return tidArguments;
4405
4868
  }
4406
4869
  }
4407
4870
 
@@ -4413,90 +4876,26 @@ class BaseAdapter3D {
4413
4876
 
4414
4877
 
4415
4878
 
4879
+
4880
+
4416
4881
  var _ArrowAnnotate;
4417
4882
  const {
4418
4883
  Point: ArrowAnnotate_TID300Point
4419
4884
  } = dcmjs_es/* utilities */.BF.TID300;
4420
4885
  const {
4421
- codeValues
4422
- } = CodingScheme;
4886
+ imageToWorldCoords: ArrowAnnotate_imageToWorldCoords
4887
+ } = esm.utilities;
4423
4888
  class ArrowAnnotate_ArrowAnnotate extends BaseAdapter3D {
4424
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata, _trackingIdentifier) {
4425
- const {
4426
- defaultState,
4427
- SCOORDGroup,
4428
- SCOORD3DGroup,
4429
- ReferencedFrameNumber
4430
- } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, ArrowAnnotate_ArrowAnnotate.toolType);
4431
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
4432
- const text = defaultState.annotation.metadata.label;
4433
- if (SCOORDGroup) {
4434
- return this.getMeasurementDataFromScoord({
4435
- SCOORDGroup,
4436
- referencedImageId,
4437
- metadata,
4438
- imageToWorldCoords,
4439
- defaultState,
4440
- text,
4441
- ReferencedFrameNumber
4442
- });
4443
- } else if (SCOORD3DGroup) {
4444
- return this.getMeasurementDataFromScoord3D({
4445
- SCOORD3DGroup,
4446
- defaultState,
4447
- text
4448
- });
4449
- } else {
4450
- throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
4451
- }
4452
- }
4453
- static getMeasurementDataFromScoord3D(_ref) {
4454
- let {
4455
- SCOORD3DGroup,
4456
- defaultState,
4457
- text
4458
- } = _ref;
4889
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, _trackingIdentifier) {
4459
4890
  const {
4460
- GraphicData
4461
- } = SCOORD3DGroup;
4462
- const worldCoords = [];
4463
- for (let i = 0; i < GraphicData.length; i += 3) {
4464
- const point = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
4465
- worldCoords.push(point);
4466
- }
4467
- const state = defaultState;
4468
- state.annotation.data = {
4469
- text,
4470
- handles: {
4471
- arrowFirst: true,
4472
- points: [worldCoords[0], worldCoords[1]],
4473
- activeHandleIndex: 0,
4474
- textBox: {
4475
- hasMoved: false
4476
- }
4477
- }
4478
- };
4479
- return state;
4480
- }
4481
- static getMeasurementDataFromScoord(_ref2) {
4482
- let {
4891
+ state,
4483
4892
  SCOORDGroup,
4893
+ worldCoords,
4484
4894
  referencedImageId,
4485
- metadata,
4486
- imageToWorldCoords,
4487
- defaultState,
4488
- text,
4489
4895
  ReferencedFrameNumber
4490
- } = _ref2;
4491
- const {
4492
- GraphicData
4493
- } = SCOORDGroup;
4494
- const worldCoords = [];
4495
- for (let i = 0; i < GraphicData.length; i += 2) {
4496
- const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
4497
- worldCoords.push(point);
4498
- }
4499
- if (worldCoords.length === 1) {
4896
+ } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
4897
+ const text = state.annotation.data.label;
4898
+ if (worldCoords.length === 1 && SCOORDGroup) {
4500
4899
  const imagePixelModule = metadata.get("imagePixelModule", referencedImageId);
4501
4900
  let xOffset = 10;
4502
4901
  let yOffset = 10;
@@ -4508,123 +4907,57 @@ class ArrowAnnotate_ArrowAnnotate extends BaseAdapter3D {
4508
4907
  xOffset = columns / 10;
4509
4908
  yOffset = rows / 10;
4510
4909
  }
4511
- const secondPoint = imageToWorldCoords(referencedImageId, [GraphicData[0] + xOffset, GraphicData[1] + yOffset]);
4910
+ const {
4911
+ GraphicData
4912
+ } = SCOORDGroup;
4913
+ const secondPoint = ArrowAnnotate_imageToWorldCoords(referencedImageId, [GraphicData[0] + xOffset, GraphicData[1] + yOffset]);
4512
4914
  worldCoords.push(secondPoint);
4513
4915
  }
4514
- const state = defaultState;
4515
4916
  state.annotation.data = {
4917
+ ...state.annotation.data,
4516
4918
  text,
4517
4919
  handles: {
4920
+ ...state.annotation.data.handles,
4518
4921
  arrowFirst: true,
4519
- points: [worldCoords[0], worldCoords[1]],
4520
- activeHandleIndex: 0,
4521
- textBox: {
4522
- hasMoved: false
4523
- }
4922
+ points: worldCoords
4524
4923
  },
4525
4924
  frameNumber: ReferencedFrameNumber
4526
4925
  };
4527
4926
  return state;
4528
4927
  }
4529
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
4928
+ static getTID300RepresentationArguments(tool) {
4929
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4530
4930
  const {
4531
4931
  data,
4532
4932
  metadata,
4533
4933
  findingSites
4534
4934
  } = tool;
4535
- let {
4935
+ const {
4536
4936
  finding
4537
4937
  } = tool;
4538
4938
  const {
4539
4939
  referencedImageId
4540
4940
  } = metadata;
4541
- if (!referencedImageId) {
4542
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
4543
- }
4544
- const {
4545
- points,
4546
- arrowFirst
4547
- } = data.handles;
4548
- let point;
4549
- let point2;
4550
- if (arrowFirst) {
4551
- point = points[0];
4552
- point2 = points[1];
4553
- } else {
4554
- point = points[1];
4555
- point2 = points[0];
4556
- }
4557
- const pointImage = worldToImageCoords(referencedImageId, point);
4558
- const pointImage2 = worldToImageCoords(referencedImageId, point2);
4559
- const TID300RepresentationArguments = {
4560
- points: [{
4561
- x: pointImage[0],
4562
- y: pointImage[1]
4563
- }, {
4564
- x: pointImage2[0],
4565
- y: pointImage2[1]
4566
- }],
4567
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
4568
- findingSites: findingSites || [],
4569
- finding,
4570
- use3DSpatialCoordinates: false
4941
+ const scoordProps = {
4942
+ is3DMeasurement,
4943
+ referencedImageId
4571
4944
  };
4572
- if (!finding || finding.CodeValue !== codeValues.CORNERSTONEFREETEXT) {
4573
- finding = {
4574
- CodeValue: codeValues.CORNERSTONEFREETEXT,
4575
- CodingSchemeDesignator: CodingScheme.CodingSchemeDesignator,
4576
- CodeMeaning: data.text
4577
- };
4578
- }
4579
- return TID300RepresentationArguments;
4580
- }
4581
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
4582
- const {
4583
- data,
4584
- findingSites,
4585
- metadata
4586
- } = tool;
4587
- let {
4588
- finding
4589
- } = tool;
4590
4945
  const {
4591
4946
  points,
4592
4947
  arrowFirst
4593
4948
  } = data.handles;
4594
- let point;
4595
- let point2;
4596
- if (arrowFirst) {
4597
- point = points[0];
4598
- point2 = points[1];
4599
- } else {
4600
- point = points[1];
4601
- point2 = points[0];
4602
- }
4603
- const pointImage = point;
4604
- const pointImage2 = point2;
4949
+ const point = arrowFirst ? points[0] : points[1];
4950
+ const point2 = arrowFirst ? points[1] : points[0];
4951
+ const pointImage = toScoord(scoordProps, point);
4952
+ const pointImage2 = toScoord(scoordProps, point2);
4605
4953
  const TID300RepresentationArguments = {
4606
- points: [{
4607
- x: pointImage[0],
4608
- y: pointImage[1],
4609
- z: pointImage[2]
4610
- }, {
4611
- x: pointImage2[0],
4612
- y: pointImage2[1],
4613
- z: pointImage2[2]
4614
- }],
4954
+ points: [pointImage, pointImage2],
4615
4955
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
4616
4956
  findingSites: findingSites || [],
4617
4957
  finding,
4618
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
4619
- use3DSpatialCoordinates: true
4958
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
4959
+ use3DSpatialCoordinates: is3DMeasurement
4620
4960
  };
4621
- if (!finding || finding.CodeValue !== codeValues.CORNERSTONEFREETEXT) {
4622
- finding = {
4623
- CodeValue: codeValues.CORNERSTONEFREETEXT,
4624
- CodingSchemeDesignator: CodingScheme.CodingSchemeDesignator,
4625
- CodeMeaning: data.text
4626
- };
4627
- }
4628
4961
  return TID300RepresentationArguments;
4629
4962
  }
4630
4963
  }
@@ -4643,6 +4976,8 @@ _ArrowAnnotate = ArrowAnnotate_ArrowAnnotate;
4643
4976
 
4644
4977
 
4645
4978
 
4979
+
4980
+
4646
4981
  var _Bidirectional;
4647
4982
  const {
4648
4983
  Bidirectional: Bidirectional_TID300Bidirectional
@@ -4650,110 +4985,43 @@ const {
4650
4985
  const Bidirectional_LONG_AXIS = "Long Axis";
4651
4986
  const Bidirectional_SHORT_AXIS = "Short Axis";
4652
4987
  class Bidirectional_Bidirectional extends BaseAdapter3D {
4653
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
4988
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
4654
4989
  const {
4655
- defaultState,
4990
+ state,
4991
+ scoordArgs,
4992
+ referencedImageId,
4656
4993
  ReferencedFrameNumber
4657
- } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, Bidirectional_Bidirectional.toolType);
4658
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
4994
+ } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
4659
4995
  const {
4660
4996
  ContentSequence
4661
4997
  } = MeasurementGroup;
4662
4998
  const longAxisNUMGroup = toArray(ContentSequence).find(group => group.ConceptNameCodeSequence.CodeMeaning === Bidirectional_LONG_AXIS);
4663
4999
  const shortAxisNUMGroup = toArray(ContentSequence).find(group => group.ConceptNameCodeSequence.CodeMeaning === Bidirectional_SHORT_AXIS);
4664
- const longAxisSCOORDGroup = toArray(longAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD");
4665
- const shortAxisSCOORDGroup = toArray(shortAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD");
4666
- if (longAxisSCOORDGroup && shortAxisSCOORDGroup) {
4667
- return this.getMeasurementDataFromScoord({
4668
- longAxisNUMGroup,
4669
- shortAxisNUMGroup,
4670
- longAxisSCOORDGroup,
4671
- shortAxisSCOORDGroup,
4672
- referencedImageId,
4673
- imageToWorldCoords,
4674
- ReferencedFrameNumber,
4675
- defaultState
4676
- });
4677
- } else {
4678
- return this.getMeasurementDataFromScoord3d({
4679
- longAxisNUMGroup,
4680
- shortAxisNUMGroup,
4681
- defaultState
4682
- });
4683
- }
4684
- }
4685
- static getMeasurementDataFromScoord(_ref) {
4686
- let {
4687
- longAxisNUMGroup,
4688
- shortAxisNUMGroup,
4689
- longAxisSCOORDGroup,
4690
- shortAxisSCOORDGroup,
4691
- referencedImageId,
4692
- imageToWorldCoords,
4693
- ReferencedFrameNumber,
4694
- defaultState
4695
- } = _ref;
5000
+ const longAxisScoordGroup = toArray(longAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD3D" || group.ValueType === "SCOORD");
5001
+ const shortAxisScoordGroup = toArray(shortAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD3D" || group.ValueType === "SCOORD");
4696
5002
  const worldCoords = [];
4697
- [longAxisSCOORDGroup, shortAxisSCOORDGroup].forEach(group => {
4698
- const {
4699
- GraphicData
4700
- } = group;
4701
- for (let i = 0; i < GraphicData.length; i += 2) {
4702
- const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
4703
- worldCoords.push(point);
4704
- }
4705
- });
4706
- const state = defaultState;
5003
+ worldCoords.push(...scoordToWorld(scoordArgs, longAxisScoordGroup));
5004
+ worldCoords.push(...scoordToWorld(scoordArgs, shortAxisScoordGroup));
4707
5005
  state.annotation.data = {
5006
+ ...state.annotation.data,
4708
5007
  handles: {
4709
- points: [worldCoords[0], worldCoords[1], worldCoords[2], worldCoords[3]],
4710
- activeHandleIndex: 0,
4711
- textBox: {
4712
- hasMoved: false
4713
- }
5008
+ ...state.annotation.data.handles,
5009
+ points: [worldCoords[0], worldCoords[1], worldCoords[2], worldCoords[3]]
4714
5010
  },
4715
- cachedStats: {
5011
+ frameNumber: ReferencedFrameNumber
5012
+ };
5013
+ if (referencedImageId) {
5014
+ state.annotation.data.cachedStats = {
4716
5015
  [`imageId:${referencedImageId}`]: {
4717
5016
  length: longAxisNUMGroup.MeasuredValueSequence.NumericValue,
4718
5017
  width: shortAxisNUMGroup.MeasuredValueSequence.NumericValue
4719
5018
  }
4720
- },
4721
- frameNumber: ReferencedFrameNumber
4722
- };
4723
- return state;
4724
- }
4725
- static getMeasurementDataFromScoord3d(_ref2) {
4726
- let {
4727
- longAxisNUMGroup,
4728
- shortAxisNUMGroup,
4729
- defaultState
4730
- } = _ref2;
4731
- const worldCoords = [];
4732
- const longAxisSCOORD3DGroup = toArray(longAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD3D");
4733
- const shortAxisSCOORD3DGroup = toArray(shortAxisNUMGroup.ContentSequence).find(group => group.ValueType === "SCOORD3D");
4734
- [longAxisSCOORD3DGroup, shortAxisSCOORD3DGroup].forEach(group => {
4735
- const {
4736
- GraphicData
4737
- } = group;
4738
- for (let i = 0; i < GraphicData.length; i += 3) {
4739
- const point = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
4740
- worldCoords.push(point);
4741
- }
4742
- });
4743
- const state = defaultState;
4744
- state.annotation.data = {
4745
- handles: {
4746
- points: [worldCoords[0], worldCoords[1], worldCoords[2], worldCoords[3]],
4747
- activeHandleIndex: 0,
4748
- textBox: {
4749
- hasMoved: false
4750
- }
4751
- },
4752
- cachedStats: {}
4753
- };
5019
+ };
5020
+ }
4754
5021
  return state;
4755
5022
  }
4756
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
5023
+ static getTID300RepresentationArguments(tool) {
5024
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4757
5025
  const {
4758
5026
  data,
4759
5027
  finding,
@@ -4767,6 +5035,10 @@ class Bidirectional_Bidirectional extends BaseAdapter3D {
4767
5035
  const {
4768
5036
  referencedImageId
4769
5037
  } = metadata;
5038
+ const scoordProps = {
5039
+ is3DMeasurement,
5040
+ referencedImageId
5041
+ };
4770
5042
  const {
4771
5043
  points
4772
5044
  } = handles;
@@ -4783,106 +5055,30 @@ class Bidirectional_Bidirectional extends BaseAdapter3D {
4783
5055
  shortAxisPoints = secondPointPairs;
4784
5056
  longAxisPoints = firstPointPairs;
4785
5057
  }
4786
- if (!referencedImageId) {
4787
- return this.getTID300RepresentationArgumentsSCOORD3D({
4788
- tool,
4789
- shortAxisPoints,
4790
- longAxisPoints
4791
- });
4792
- }
4793
- const longAxisStartImage = worldToImageCoords(referencedImageId, shortAxisPoints[0]);
4794
- const longAxisEndImage = worldToImageCoords(referencedImageId, shortAxisPoints[1]);
4795
- const shortAxisStartImage = worldToImageCoords(referencedImageId, longAxisPoints[0]);
4796
- const shortAxisEndImage = worldToImageCoords(referencedImageId, longAxisPoints[1]);
5058
+ const longAxisStartImage = toScoord(scoordProps, shortAxisPoints[0]);
5059
+ const longAxisEndImage = toScoord(scoordProps, shortAxisPoints[1]);
5060
+ const shortAxisStartImage = toScoord(scoordProps, longAxisPoints[0]);
5061
+ const shortAxisEndImage = toScoord(scoordProps, longAxisPoints[1]);
4797
5062
  const {
4798
5063
  length,
4799
5064
  width
4800
5065
  } = cachedStats[`imageId:${referencedImageId}`] || {};
4801
5066
  return {
4802
5067
  longAxis: {
4803
- point1: {
4804
- x: longAxisStartImage[0],
4805
- y: longAxisStartImage[1]
4806
- },
4807
- point2: {
4808
- x: longAxisEndImage[0],
4809
- y: longAxisEndImage[1]
4810
- }
4811
- },
4812
- shortAxis: {
4813
- point1: {
4814
- x: shortAxisStartImage[0],
4815
- y: shortAxisStartImage[1]
4816
- },
4817
- point2: {
4818
- x: shortAxisEndImage[0],
4819
- y: shortAxisEndImage[1]
4820
- }
4821
- },
4822
- longAxisLength: length,
4823
- shortAxisLength: width,
4824
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
4825
- finding: finding,
4826
- findingSites: findingSites || [],
4827
- use3DSpatialCoordinates: false
4828
- };
4829
- }
4830
- static getTID300RepresentationArgumentsSCOORD3D(_ref3) {
4831
- let {
4832
- tool,
4833
- shortAxisPoints,
4834
- longAxisPoints
4835
- } = _ref3;
4836
- const {
4837
- data,
4838
- finding,
4839
- findingSites,
4840
- metadata
4841
- } = tool;
4842
- const {
4843
- cachedStats = {}
4844
- } = data;
4845
- const longAxisStart = shortAxisPoints[0];
4846
- const longAxisEnd = shortAxisPoints[1];
4847
- const shortAxisStart = longAxisPoints[0];
4848
- const shortAxisEnd = longAxisPoints[1];
4849
- const cachedStatsKeys = Object.keys(cachedStats)[0];
4850
- const {
4851
- length = undefined,
4852
- width = undefined
4853
- } = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
4854
- return {
4855
- longAxis: {
4856
- point1: {
4857
- x: longAxisStart[0],
4858
- y: longAxisStart[1],
4859
- z: longAxisStart[2]
4860
- },
4861
- point2: {
4862
- x: longAxisEnd[0],
4863
- y: longAxisEnd[1],
4864
- z: longAxisEnd[2]
4865
- }
5068
+ point1: longAxisStartImage,
5069
+ point2: longAxisEndImage
4866
5070
  },
4867
5071
  shortAxis: {
4868
- point1: {
4869
- x: shortAxisStart[0],
4870
- y: shortAxisStart[1],
4871
- z: shortAxisStart[2]
4872
- },
4873
- point2: {
4874
- x: shortAxisEnd[0],
4875
- y: shortAxisEnd[1],
4876
- z: shortAxisEnd[2]
4877
- }
5072
+ point1: shortAxisStartImage,
5073
+ point2: shortAxisEndImage
4878
5074
  },
4879
5075
  longAxisLength: length,
4880
5076
  shortAxisLength: width,
4881
5077
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
4882
5078
  finding: finding,
4883
5079
  findingSites: findingSites || [],
4884
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
4885
- use3DSpatialCoordinates: true
5080
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
5081
+ use3DSpatialCoordinates: is3DMeasurement
4886
5082
  };
4887
5083
  }
4888
5084
  }
@@ -4899,98 +5095,40 @@ _Bidirectional = Bidirectional_Bidirectional;
4899
5095
 
4900
5096
 
4901
5097
 
5098
+
5099
+
5100
+
4902
5101
  var _Angle;
4903
5102
  const {
4904
5103
  CobbAngle: Angle_TID300CobbAngle
4905
5104
  } = dcmjs_es/* utilities */.BF.TID300;
4906
5105
  class Angle_Angle extends BaseAdapter3D {
4907
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
5106
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
4908
5107
  const {
4909
- defaultState,
4910
- NUMGroup,
4911
- SCOORDGroup,
4912
- SCOORD3DGroup,
4913
- ReferencedFrameNumber
4914
- } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, Angle_Angle.toolType);
4915
- if (SCOORDGroup) {
4916
- return this.getMeasurementDataFromScoord({
4917
- defaultState,
4918
- SCOORDGroup,
4919
- imageToWorldCoords,
4920
- NUMGroup,
4921
- ReferencedFrameNumber
4922
- });
4923
- } else if (SCOORD3DGroup) {
4924
- return this.getMeasurementDataFromScoord3D({
4925
- defaultState,
4926
- SCOORD3DGroup
4927
- });
4928
- } else {
4929
- throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
4930
- }
4931
- }
4932
- static getMeasurementDataFromScoord(_ref) {
4933
- let {
4934
- defaultState,
4935
- SCOORDGroup,
4936
- imageToWorldCoords,
5108
+ state,
4937
5109
  NUMGroup,
5110
+ worldCoords,
5111
+ referencedImageId,
4938
5112
  ReferencedFrameNumber
4939
- } = _ref;
4940
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
4941
- const {
4942
- GraphicData
4943
- } = SCOORDGroup;
4944
- const worldCoords = [];
4945
- for (let i = 0; i < GraphicData.length; i += 2) {
4946
- const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
4947
- worldCoords.push(point);
4948
- }
4949
- const state = defaultState;
5113
+ } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
5114
+ const cachedStats = referencedImageId ? {
5115
+ [`imageId:${referencedImageId}`]: {
5116
+ angle: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : null
5117
+ }
5118
+ } : {};
4950
5119
  state.annotation.data = {
5120
+ ...state.annotation.data,
4951
5121
  handles: {
4952
- points: [worldCoords[0], worldCoords[1], worldCoords[3]],
4953
- activeHandleIndex: 0,
4954
- textBox: {
4955
- hasMoved: false
4956
- }
4957
- },
4958
- cachedStats: {
4959
- [`imageId:${referencedImageId}`]: {
4960
- angle: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : null
4961
- }
5122
+ ...state.annotation.data.handles,
5123
+ points: [worldCoords[0], worldCoords[1], worldCoords[3]]
4962
5124
  },
5125
+ cachedStats,
4963
5126
  frameNumber: ReferencedFrameNumber
4964
5127
  };
4965
5128
  return state;
4966
5129
  }
4967
- static getMeasurementDataFromScoord3D(_ref2) {
4968
- let {
4969
- defaultState,
4970
- SCOORD3DGroup
4971
- } = _ref2;
4972
- const {
4973
- GraphicData
4974
- } = SCOORD3DGroup;
4975
- const worldCoords = [];
4976
- for (let i = 0; i < GraphicData.length; i += 3) {
4977
- const point = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
4978
- worldCoords.push(point);
4979
- }
4980
- const state = defaultState;
4981
- state.annotation.data = {
4982
- handles: {
4983
- points: [worldCoords[0], worldCoords[1], worldCoords[3]],
4984
- activeHandleIndex: 0,
4985
- textBox: {
4986
- hasMoved: false
4987
- }
4988
- },
4989
- cachedStats: {}
4990
- };
4991
- return state;
4992
- }
4993
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
5130
+ static getTID300RepresentationArguments(tool) {
5131
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
4994
5132
  const {
4995
5133
  data,
4996
5134
  finding,
@@ -5004,74 +5142,15 @@ class Angle_Angle extends BaseAdapter3D {
5004
5142
  const {
5005
5143
  referencedImageId
5006
5144
  } = metadata;
5007
- if (!referencedImageId) {
5008
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
5009
- }
5010
- const start1 = worldToImageCoords(referencedImageId, handles.points[0]);
5011
- const middle = worldToImageCoords(referencedImageId, handles.points[1]);
5012
- const end = worldToImageCoords(referencedImageId, handles.points[2]);
5013
- const point1 = {
5014
- x: start1[0],
5015
- y: start1[1]
5016
- };
5017
- const point2 = {
5018
- x: middle[0],
5019
- y: middle[1]
5020
- };
5021
- const point3 = point2;
5022
- const point4 = {
5023
- x: end[0],
5024
- y: end[1]
5025
- };
5026
- const {
5027
- angle
5028
- } = cachedStats[`imageId:${referencedImageId}`] || {};
5029
- return {
5030
- point1,
5031
- point2,
5032
- point3,
5033
- point4,
5034
- rAngle: angle,
5035
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
5036
- finding,
5037
- findingSites: findingSites || [],
5038
- use3DSpatialCoordinates: false
5039
- };
5040
- }
5041
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
5042
- const {
5043
- data,
5044
- finding,
5045
- findingSites,
5046
- metadata
5047
- } = tool;
5048
- const {
5049
- cachedStats = {},
5050
- handles
5051
- } = data;
5052
- const start = handles.points[0];
5053
- const middle = handles.points[1];
5054
- const end = handles.points[2];
5055
- const point1 = {
5056
- x: start[0],
5057
- y: start[1],
5058
- z: start[2]
5059
- };
5060
- const point2 = {
5061
- x: middle[0],
5062
- y: middle[1],
5063
- z: middle[2]
5064
- };
5065
- const point3 = point2;
5066
- const point4 = {
5067
- x: end[0],
5068
- y: end[1],
5069
- z: end[2]
5145
+ const scoordProps = {
5146
+ is3DMeasurement,
5147
+ referencedImageId
5070
5148
  };
5071
- const cachedStatsKeys = Object.keys(cachedStats)[0];
5072
- const {
5073
- angle = undefined
5074
- } = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
5149
+ const point1 = toScoord(scoordProps, handles.points[0]);
5150
+ const point2 = toScoord(scoordProps, handles.points[1]);
5151
+ const point3 = toScoord(scoordProps, handles.points[1]);
5152
+ const point4 = toScoord(scoordProps, handles.points[2]);
5153
+ const angle = cachedStats[`imageId:${referencedImageId}`]?.angle;
5075
5154
  return {
5076
5155
  point1,
5077
5156
  point2,
@@ -5081,8 +5160,8 @@ class Angle_Angle extends BaseAdapter3D {
5081
5160
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
5082
5161
  finding,
5083
5162
  findingSites: findingSites || [],
5084
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
5085
- use3DSpatialCoordinates: true
5163
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
5164
+ use3DSpatialCoordinates: is3DMeasurement
5086
5165
  };
5087
5166
  }
5088
5167
  }
@@ -5099,98 +5178,41 @@ _Angle = Angle_Angle;
5099
5178
 
5100
5179
 
5101
5180
 
5181
+
5182
+
5183
+
5102
5184
  var _CobbAngle;
5103
5185
  const {
5104
5186
  CobbAngle: CobbAngle_TID300CobbAngle
5105
5187
  } = dcmjs_es/* utilities */.BF.TID300;
5106
5188
  class CobbAngle_CobbAngle extends BaseAdapter3D {
5107
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
5189
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
5108
5190
  const {
5109
- defaultState,
5191
+ state,
5110
5192
  NUMGroup,
5111
- SCOORDGroup,
5112
- SCOORD3DGroup,
5193
+ referencedImageId,
5194
+ worldCoords,
5113
5195
  ReferencedFrameNumber
5114
5196
  } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, CobbAngle_CobbAngle.toolType);
5115
- if (SCOORDGroup) {
5116
- return this.getMeasurementDataFromScoord({
5117
- defaultState,
5118
- SCOORDGroup,
5119
- imageToWorldCoords,
5120
- NUMGroup,
5121
- ReferencedFrameNumber
5122
- });
5123
- } else if (SCOORD3DGroup) {
5124
- return this.getMeasurementDataFromScoord3D({
5125
- defaultState,
5126
- SCOORD3DGroup
5127
- });
5128
- } else {
5129
- throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
5130
- }
5131
- }
5132
- static getMeasurementDataFromScoord(_ref) {
5133
- let {
5134
- defaultState,
5135
- SCOORDGroup,
5136
- imageToWorldCoords,
5137
- NUMGroup,
5138
- ReferencedFrameNumber
5139
- } = _ref;
5140
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
5141
- const {
5142
- GraphicData
5143
- } = SCOORDGroup;
5144
- const worldCoords = [];
5145
- for (let i = 0; i < GraphicData.length; i += 2) {
5146
- const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
5147
- worldCoords.push(point);
5148
- }
5149
- const state = defaultState;
5150
5197
  state.annotation.data = {
5198
+ ...state.annotation.data,
5151
5199
  handles: {
5152
- points: [worldCoords[0], worldCoords[1], worldCoords[2], worldCoords[3]],
5153
- activeHandleIndex: 0,
5154
- textBox: {
5155
- hasMoved: false
5156
- }
5200
+ ...state.annotation.data.handles,
5201
+ points: [worldCoords[0], worldCoords[1], worldCoords[2], worldCoords[3]]
5157
5202
  },
5158
- cachedStats: {
5203
+ frameNumber: ReferencedFrameNumber
5204
+ };
5205
+ if (referencedImageId) {
5206
+ state.annotation.data.cachedStats = {
5159
5207
  [`imageId:${referencedImageId}`]: {
5160
5208
  angle: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : null
5161
5209
  }
5162
- },
5163
- frameNumber: ReferencedFrameNumber
5164
- };
5165
- return state;
5166
- }
5167
- static getMeasurementDataFromScoord3D(_ref2) {
5168
- let {
5169
- defaultState,
5170
- SCOORD3DGroup
5171
- } = _ref2;
5172
- const {
5173
- GraphicData
5174
- } = SCOORD3DGroup;
5175
- const worldCoords = [];
5176
- for (let i = 0; i < GraphicData.length; i += 3) {
5177
- const point = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
5178
- worldCoords.push(point);
5210
+ };
5179
5211
  }
5180
- const state = defaultState;
5181
- state.annotation.data = {
5182
- handles: {
5183
- points: [worldCoords[0], worldCoords[1], worldCoords[2], worldCoords[3]],
5184
- activeHandleIndex: 0,
5185
- textBox: {
5186
- hasMoved: false
5187
- }
5188
- },
5189
- cachedStats: {}
5190
- };
5191
5212
  return state;
5192
5213
  }
5193
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
5214
+ static getTID300RepresentationArguments(tool) {
5215
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5194
5216
  const {
5195
5217
  data,
5196
5218
  finding,
@@ -5204,29 +5226,12 @@ class CobbAngle_CobbAngle extends BaseAdapter3D {
5204
5226
  const {
5205
5227
  referencedImageId
5206
5228
  } = metadata;
5207
- if (!referencedImageId) {
5208
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
5209
- }
5210
- const start1 = worldToImageCoords(referencedImageId, handles.points[0]);
5211
- const end1 = worldToImageCoords(referencedImageId, handles.points[1]);
5212
- const start2 = worldToImageCoords(referencedImageId, handles.points[2]);
5213
- const end2 = worldToImageCoords(referencedImageId, handles.points[3]);
5214
- const point1 = {
5215
- x: start1[0],
5216
- y: start1[1]
5217
- };
5218
- const point2 = {
5219
- x: end1[0],
5220
- y: end1[1]
5221
- };
5222
- const point3 = {
5223
- x: start2[0],
5224
- y: start2[1]
5225
- };
5226
- const point4 = {
5227
- x: end2[0],
5228
- y: end2[1]
5229
+ const scoordProps = {
5230
+ is3DMeasurement,
5231
+ referencedImageId
5229
5232
  };
5233
+ const points = toScoords(scoordProps, handles.points);
5234
+ const [point1, point2, point3, point4] = points;
5230
5235
  const {
5231
5236
  angle
5232
5237
  } = cachedStats[`imageId:${referencedImageId}`] || {};
@@ -5239,59 +5244,8 @@ class CobbAngle_CobbAngle extends BaseAdapter3D {
5239
5244
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
5240
5245
  finding,
5241
5246
  findingSites: findingSites || [],
5242
- use3DSpatialCoordinates: false
5243
- };
5244
- }
5245
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
5246
- const {
5247
- data,
5248
- finding,
5249
- findingSites,
5250
- metadata
5251
- } = tool;
5252
- const {
5253
- cachedStats = {},
5254
- handles
5255
- } = data;
5256
- const start1 = handles.points[0];
5257
- const end1 = handles.points[1];
5258
- const start2 = handles.points[2];
5259
- const end2 = handles.points[3];
5260
- const point1 = {
5261
- x: start1[0],
5262
- y: start1[1],
5263
- z: start1[2]
5264
- };
5265
- const point2 = {
5266
- x: end1[0],
5267
- y: end1[1],
5268
- z: end1[2]
5269
- };
5270
- const point3 = {
5271
- x: start2[0],
5272
- y: start2[1],
5273
- z: start2[2]
5274
- };
5275
- const point4 = {
5276
- x: end2[0],
5277
- y: end2[1],
5278
- z: end2[2]
5279
- };
5280
- const cachedStatsKeys = Object.keys(cachedStats)[0];
5281
- const {
5282
- angle = undefined
5283
- } = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
5284
- return {
5285
- point1,
5286
- point2,
5287
- point3,
5288
- point4,
5289
- rAngle: angle,
5290
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
5291
- finding,
5292
- findingSites: findingSites || [],
5293
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
5294
- use3DSpatialCoordinates: true
5247
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
5248
+ use3DSpatialCoordinates: is3DMeasurement
5295
5249
  };
5296
5250
  }
5297
5251
  }
@@ -5308,100 +5262,43 @@ _CobbAngle = CobbAngle_CobbAngle;
5308
5262
 
5309
5263
 
5310
5264
 
5265
+
5266
+
5267
+
5311
5268
  var _CircleROI;
5312
5269
  const {
5313
5270
  Circle: CircleROI_TID300Circle
5314
5271
  } = dcmjs_es/* utilities */.BF.TID300;
5315
5272
  class CircleROI extends BaseAdapter3D {
5316
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
5273
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
5317
5274
  const {
5318
- defaultState,
5319
- NUMGroup,
5320
- SCOORDGroup,
5321
- SCOORD3DGroup,
5322
- ReferencedFrameNumber
5323
- } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, CircleROI.toolType);
5324
- if (SCOORDGroup) {
5325
- return this.getMeasurementDataFromScoord({
5326
- defaultState,
5327
- SCOORDGroup,
5328
- imageToWorldCoords,
5329
- NUMGroup,
5330
- ReferencedFrameNumber
5331
- });
5332
- } else if (SCOORD3DGroup) {
5333
- return this.getMeasurementDataFromScoord3D({
5334
- defaultState,
5335
- SCOORD3DGroup
5336
- });
5337
- } else {
5338
- throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
5339
- }
5340
- }
5341
- static getMeasurementDataFromScoord(_ref) {
5342
- let {
5343
- defaultState,
5344
- SCOORDGroup,
5345
- imageToWorldCoords,
5275
+ state,
5346
5276
  NUMGroup,
5277
+ worldCoords,
5278
+ referencedImageId,
5347
5279
  ReferencedFrameNumber
5348
- } = _ref;
5349
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
5350
- const {
5351
- GraphicData
5352
- } = SCOORDGroup;
5353
- const pointsWorld = [];
5354
- for (let i = 0; i < GraphicData.length; i += 2) {
5355
- const worldPos = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
5356
- pointsWorld.push(worldPos);
5357
- }
5358
- const state = defaultState;
5280
+ } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
5359
5281
  state.annotation.data = {
5282
+ ...state.annotation.data,
5360
5283
  handles: {
5361
- points: [...pointsWorld],
5362
- activeHandleIndex: 0,
5363
- textBox: {
5364
- hasMoved: false
5365
- }
5284
+ ...state.annotation.data.handles,
5285
+ points: worldCoords
5366
5286
  },
5367
- cachedStats: {
5287
+ frameNumber: ReferencedFrameNumber
5288
+ };
5289
+ if (referencedImageId) {
5290
+ state.annotation.data.cachedStats = {
5368
5291
  [`imageId:${referencedImageId}`]: {
5369
5292
  area: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : 0,
5370
5293
  radius: 0,
5371
5294
  perimeter: 0
5372
5295
  }
5373
- },
5374
- frameNumber: ReferencedFrameNumber
5375
- };
5376
- return state;
5377
- }
5378
- static getMeasurementDataFromScoord3D(_ref2) {
5379
- let {
5380
- defaultState,
5381
- SCOORD3DGroup
5382
- } = _ref2;
5383
- const {
5384
- GraphicData
5385
- } = SCOORD3DGroup;
5386
- const pointsWorld = [];
5387
- for (let i = 0; i < GraphicData.length; i += 3) {
5388
- const worldPos = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
5389
- pointsWorld.push(worldPos);
5296
+ };
5390
5297
  }
5391
- const state = defaultState;
5392
- state.annotation.data = {
5393
- handles: {
5394
- points: [...pointsWorld],
5395
- activeHandleIndex: 0,
5396
- textBox: {
5397
- hasMoved: false
5398
- }
5399
- },
5400
- cachedStats: {}
5401
- };
5402
5298
  return state;
5403
5299
  }
5404
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
5300
+ static getTID300RepresentationArguments(tool) {
5301
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5405
5302
  const {
5406
5303
  data,
5407
5304
  finding,
@@ -5415,20 +5312,12 @@ class CircleROI extends BaseAdapter3D {
5415
5312
  const {
5416
5313
  referencedImageId
5417
5314
  } = metadata;
5418
- if (!referencedImageId) {
5419
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
5420
- }
5421
- const center = worldToImageCoords(referencedImageId, handles.points[0]);
5422
- const end = worldToImageCoords(referencedImageId, handles.points[1]);
5423
- const points = [];
5424
- points.push({
5425
- x: center[0],
5426
- y: center[1]
5427
- });
5428
- points.push({
5429
- x: end[0],
5430
- y: end[1]
5431
- });
5315
+ const scoordProps = {
5316
+ is3DMeasurement,
5317
+ referencedImageId
5318
+ };
5319
+ const center = toScoord(scoordProps, handles.points[0]);
5320
+ const end = toScoord(scoordProps, handles.points[1]);
5432
5321
  const {
5433
5322
  area,
5434
5323
  radius
@@ -5438,53 +5327,12 @@ class CircleROI extends BaseAdapter3D {
5438
5327
  area,
5439
5328
  perimeter,
5440
5329
  radius,
5441
- points,
5442
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
5443
- finding,
5444
- findingSites: findingSites || [],
5445
- use3DSpatialCoordinates: false
5446
- };
5447
- }
5448
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
5449
- const {
5450
- data,
5451
- finding,
5452
- findingSites,
5453
- metadata
5454
- } = tool;
5455
- const {
5456
- cachedStats = {},
5457
- handles
5458
- } = data;
5459
- const center = handles.points[0];
5460
- const end = handles.points[1];
5461
- const points = [];
5462
- points.push({
5463
- x: center[0],
5464
- y: center[1],
5465
- z: center[2]
5466
- });
5467
- points.push({
5468
- x: end[0],
5469
- y: end[1],
5470
- z: center[2]
5471
- });
5472
- const cachedStatsKeys = Object.keys(cachedStats)[0];
5473
- const {
5474
- area = undefined,
5475
- radius = 0
5476
- } = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
5477
- const perimeter = 2 * Math.PI * radius;
5478
- return {
5479
- area,
5480
- perimeter,
5481
- radius,
5482
- points,
5330
+ points: [center, end],
5483
5331
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
5484
5332
  finding,
5485
5333
  findingSites: findingSites || [],
5486
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
5487
- use3DSpatialCoordinates: true
5334
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
5335
+ use3DSpatialCoordinates: is3DMeasurement
5488
5336
  };
5489
5337
  }
5490
5338
  }
@@ -5496,149 +5344,44 @@ _CircleROI = CircleROI;
5496
5344
 
5497
5345
 
5498
5346
 
5499
- // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/index.js + 1 modules
5500
- var gl_matrix_esm = __webpack_require__(3823);
5501
5347
  ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/Cornerstone3D/EllipticalROI.js
5502
5348
 
5503
5349
 
5504
5350
 
5505
5351
 
5506
5352
 
5353
+
5354
+
5507
5355
  var _EllipticalROI;
5508
5356
  const {
5509
5357
  Ellipse: EllipticalROI_TID300Ellipse
5510
5358
  } = dcmjs_es/* utilities */.BF.TID300;
5511
- const EPSILON = 1e-4;
5512
5359
  class EllipticalROI extends BaseAdapter3D {
5513
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
5360
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
5514
5361
  const {
5515
- defaultState,
5362
+ state,
5516
5363
  NUMGroup,
5517
- SCOORDGroup,
5518
- SCOORD3DGroup,
5364
+ worldCoords,
5365
+ referencedImageId,
5519
5366
  ReferencedFrameNumber
5520
5367
  } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, EllipticalROI.toolType);
5521
- if (SCOORDGroup) {
5522
- return this.getMeasurementDataFromScoord({
5523
- defaultState,
5524
- SCOORDGroup,
5525
- imageToWorldCoords,
5526
- metadata,
5527
- NUMGroup,
5528
- ReferencedFrameNumber
5529
- });
5530
- } else if (SCOORD3DGroup) {
5531
- return this.getMeasurementDataFromScoord3D({
5532
- defaultState,
5533
- SCOORD3DGroup
5534
- });
5535
- } else {
5536
- throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
5537
- }
5538
- }
5539
- static getMeasurementDataFromScoord(_ref) {
5540
- let {
5541
- defaultState,
5542
- SCOORDGroup,
5543
- imageToWorldCoords,
5544
- metadata,
5545
- NUMGroup,
5546
- ReferencedFrameNumber
5547
- } = _ref;
5548
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
5549
- const {
5550
- GraphicData
5551
- } = SCOORDGroup;
5552
- const pointsWorld = [];
5553
- for (let i = 0; i < GraphicData.length; i += 2) {
5554
- const worldPos = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
5555
- pointsWorld.push(worldPos);
5556
- }
5557
- const majorAxisStart = gl_matrix_esm/* vec3.fromValues */.eR.fromValues(...pointsWorld[0]);
5558
- const majorAxisEnd = gl_matrix_esm/* vec3.fromValues */.eR.fromValues(...pointsWorld[1]);
5559
- const minorAxisStart = gl_matrix_esm/* vec3.fromValues */.eR.fromValues(...pointsWorld[2]);
5560
- const minorAxisEnd = gl_matrix_esm/* vec3.fromValues */.eR.fromValues(...pointsWorld[3]);
5561
- const majorAxisVec = gl_matrix_esm/* vec3.create */.eR.create();
5562
- gl_matrix_esm/* vec3.sub */.eR.sub(majorAxisVec, majorAxisEnd, majorAxisStart);
5563
- gl_matrix_esm/* vec3.normalize */.eR.normalize(majorAxisVec, majorAxisVec);
5564
- const minorAxisVec = gl_matrix_esm/* vec3.create */.eR.create();
5565
- gl_matrix_esm/* vec3.sub */.eR.sub(minorAxisVec, minorAxisEnd, minorAxisStart);
5566
- gl_matrix_esm/* vec3.normalize */.eR.normalize(minorAxisVec, minorAxisVec);
5567
- const imagePlaneModule = metadata.get("imagePlaneModule", referencedImageId);
5568
- if (!imagePlaneModule) {
5569
- throw new Error("imageId does not have imagePlaneModule metadata");
5570
- }
5571
- const {
5572
- columnCosines
5573
- } = imagePlaneModule;
5574
- const columnCosinesVec = gl_matrix_esm/* vec3.fromValues */.eR.fromValues(columnCosines[0], columnCosines[1], columnCosines[2]);
5575
- const projectedMajorAxisOnColVec = gl_matrix_esm/* vec3.dot */.eR.dot(columnCosinesVec, majorAxisVec);
5576
- const projectedMinorAxisOnColVec = gl_matrix_esm/* vec3.dot */.eR.dot(columnCosinesVec, minorAxisVec);
5577
- const absoluteOfMajorDotProduct = Math.abs(projectedMajorAxisOnColVec);
5578
- const absoluteOfMinorDotProduct = Math.abs(projectedMinorAxisOnColVec);
5579
- let ellipsePoints = [];
5580
- if (Math.abs(absoluteOfMajorDotProduct - 1) < EPSILON) {
5581
- ellipsePoints = [pointsWorld[0], pointsWorld[1], pointsWorld[2], pointsWorld[3]];
5582
- } else if (Math.abs(absoluteOfMinorDotProduct - 1) < EPSILON) {
5583
- ellipsePoints = [pointsWorld[2], pointsWorld[3], pointsWorld[0], pointsWorld[1]];
5584
- } else {
5585
- console.warn("OBLIQUE ELLIPSE NOT YET SUPPORTED");
5586
- }
5587
- const state = defaultState;
5588
5368
  state.annotation.data = {
5369
+ ...state.annotation.data,
5589
5370
  handles: {
5590
- points: [...ellipsePoints],
5591
- activeHandleIndex: 0,
5592
- textBox: {
5593
- hasMoved: false
5594
- }
5595
- },
5596
- cachedStats: {
5597
- [`imageId:${referencedImageId}`]: {
5598
- area: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : 0
5599
- }
5371
+ ...state.annotation.data.handles,
5372
+ points: worldCoords
5600
5373
  },
5601
5374
  frameNumber: ReferencedFrameNumber
5602
5375
  };
5376
+ state.annotation.data.cachedStats = referencedImageId ? {
5377
+ [`imageId:${referencedImageId}`]: {
5378
+ area: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : 0
5379
+ }
5380
+ } : {};
5603
5381
  return state;
5604
5382
  }
5605
- static getMeasurementDataFromScoord3D(_ref2) {
5606
- let {
5607
- defaultState,
5608
- SCOORD3DGroup
5609
- } = _ref2;
5610
- const {
5611
- GraphicData
5612
- } = SCOORD3DGroup;
5613
- const pointsWorld = [];
5614
- for (let i = 0; i < GraphicData.length; i += 3) {
5615
- const worldPos = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
5616
- pointsWorld.push(worldPos);
5617
- }
5618
- const majorAxisStart = gl_matrix_esm/* vec3.fromValues */.eR.fromValues(...pointsWorld[0]);
5619
- const majorAxisEnd = gl_matrix_esm/* vec3.fromValues */.eR.fromValues(...pointsWorld[1]);
5620
- const minorAxisStart = gl_matrix_esm/* vec3.fromValues */.eR.fromValues(...pointsWorld[2]);
5621
- const minorAxisEnd = gl_matrix_esm/* vec3.fromValues */.eR.fromValues(...pointsWorld[3]);
5622
- const majorAxisVec = gl_matrix_esm/* vec3.create */.eR.create();
5623
- gl_matrix_esm/* vec3.sub */.eR.sub(majorAxisVec, majorAxisEnd, majorAxisStart);
5624
- gl_matrix_esm/* vec3.normalize */.eR.normalize(majorAxisVec, majorAxisVec);
5625
- const minorAxisVec = gl_matrix_esm/* vec3.create */.eR.create();
5626
- gl_matrix_esm/* vec3.sub */.eR.sub(minorAxisVec, minorAxisEnd, minorAxisStart);
5627
- gl_matrix_esm/* vec3.normalize */.eR.normalize(minorAxisVec, minorAxisVec);
5628
- const state = defaultState;
5629
- state.annotation.data = {
5630
- handles: {
5631
- points: [majorAxisStart, majorAxisEnd, minorAxisStart, minorAxisEnd],
5632
- activeHandleIndex: 0,
5633
- textBox: {
5634
- hasMoved: false
5635
- }
5636
- },
5637
- cachedStats: {}
5638
- };
5639
- return state;
5640
- }
5641
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
5383
+ static getTID300RepresentationArguments(tool) {
5384
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5642
5385
  const {
5643
5386
  data,
5644
5387
  finding,
@@ -5653,83 +5396,10 @@ class EllipticalROI extends BaseAdapter3D {
5653
5396
  const {
5654
5397
  referencedImageId
5655
5398
  } = metadata;
5656
- if (!referencedImageId) {
5657
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
5658
- }
5659
- let top, bottom, left, right;
5660
- if (rotation == 90 || rotation == 270) {
5661
- bottom = worldToImageCoords(referencedImageId, handles.points[2]);
5662
- top = worldToImageCoords(referencedImageId, handles.points[3]);
5663
- left = worldToImageCoords(referencedImageId, handles.points[0]);
5664
- right = worldToImageCoords(referencedImageId, handles.points[1]);
5665
- } else {
5666
- top = worldToImageCoords(referencedImageId, handles.points[0]);
5667
- bottom = worldToImageCoords(referencedImageId, handles.points[1]);
5668
- left = worldToImageCoords(referencedImageId, handles.points[2]);
5669
- right = worldToImageCoords(referencedImageId, handles.points[3]);
5670
- }
5671
- const topBottomLength = Math.abs(top[1] - bottom[1]);
5672
- const leftRightLength = Math.abs(left[0] - right[0]);
5673
- const points = [];
5674
- if (topBottomLength > leftRightLength) {
5675
- points.push({
5676
- x: top[0],
5677
- y: top[1]
5678
- });
5679
- points.push({
5680
- x: bottom[0],
5681
- y: bottom[1]
5682
- });
5683
- points.push({
5684
- x: left[0],
5685
- y: left[1]
5686
- });
5687
- points.push({
5688
- x: right[0],
5689
- y: right[1]
5690
- });
5691
- } else {
5692
- points.push({
5693
- x: left[0],
5694
- y: left[1]
5695
- });
5696
- points.push({
5697
- x: right[0],
5698
- y: right[1]
5699
- });
5700
- points.push({
5701
- x: top[0],
5702
- y: top[1]
5703
- });
5704
- points.push({
5705
- x: bottom[0],
5706
- y: bottom[1]
5707
- });
5708
- }
5709
- const {
5710
- area
5711
- } = cachedStats[`imageId:${referencedImageId}`] || {};
5712
- return {
5713
- area,
5714
- points,
5715
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
5716
- finding,
5717
- findingSites: findingSites || [],
5718
- use3DSpatialCoordinates: false
5399
+ const scoordProps = {
5400
+ is3DMeasurement,
5401
+ referencedImageId
5719
5402
  };
5720
- }
5721
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
5722
- const {
5723
- data,
5724
- finding,
5725
- findingSites,
5726
- metadata
5727
- } = tool;
5728
- const {
5729
- cachedStats,
5730
- handles
5731
- } = data;
5732
- const rotation = data.initialRotation || 0;
5733
5403
  let top, bottom, left, right;
5734
5404
  if (rotation == 90 || rotation == 270) {
5735
5405
  bottom = handles.points[2];
@@ -5746,60 +5416,22 @@ class EllipticalROI extends BaseAdapter3D {
5746
5416
  const leftRightLength = Math.sqrt((left[0] - right[0]) ** 2 + (left[1] - right[1]) ** 2 + (left[2] - right[2]) ** 2);
5747
5417
  const points = [];
5748
5418
  if (topBottomLength > leftRightLength) {
5749
- points.push({
5750
- x: top[0],
5751
- y: top[1],
5752
- z: top[2]
5753
- });
5754
- points.push({
5755
- x: bottom[0],
5756
- y: bottom[1],
5757
- z: bottom[2]
5758
- });
5759
- points.push({
5760
- x: left[0],
5761
- y: left[1],
5762
- z: left[2]
5763
- });
5764
- points.push({
5765
- x: right[0],
5766
- y: right[1],
5767
- z: right[2]
5768
- });
5419
+ points.push(top, bottom, left, right);
5769
5420
  } else {
5770
- points.push({
5771
- x: left[0],
5772
- y: left[1],
5773
- z: left[2]
5774
- });
5775
- points.push({
5776
- x: right[0],
5777
- y: right[1],
5778
- z: right[2]
5779
- });
5780
- points.push({
5781
- x: top[0],
5782
- y: top[1],
5783
- z: top[2]
5784
- });
5785
- points.push({
5786
- x: bottom[0],
5787
- y: bottom[1],
5788
- z: bottom[2]
5789
- });
5421
+ points.push(left, right, top, bottom);
5790
5422
  }
5791
- const cachedStatsKeys = Object.keys(cachedStats)[0];
5792
5423
  const {
5793
- area = undefined
5794
- } = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
5424
+ area
5425
+ } = cachedStats[`imageId:${referencedImageId}`] || {};
5426
+ const convertedPoints = points.map(point => toScoord(scoordProps, point));
5795
5427
  return {
5796
5428
  area,
5797
- points,
5429
+ points: convertedPoints,
5798
5430
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
5799
5431
  finding,
5800
5432
  findingSites: findingSites || [],
5801
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
5802
- use3DSpatialCoordinates: true
5433
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
5434
+ use3DSpatialCoordinates: is3DMeasurement
5803
5435
  };
5804
5436
  }
5805
5437
  }
@@ -5813,145 +5445,59 @@ _EllipticalROI.init("EllipticalROI", EllipticalROI_TID300Ellipse);
5813
5445
 
5814
5446
 
5815
5447
 
5448
+
5449
+
5450
+
5816
5451
  var _RectangleROI;
5817
5452
  const {
5818
5453
  Polyline: RectangleROI_TID300Polyline
5819
5454
  } = dcmjs_es/* utilities */.BF.TID300;
5820
5455
  class RectangleROI extends BaseAdapter3D {
5821
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
5456
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
5822
5457
  const {
5823
- defaultState,
5824
- NUMGroup,
5825
- SCOORDGroup,
5826
- SCOORD3DGroup,
5827
- ReferencedFrameNumber
5828
- } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, RectangleROI.toolType);
5829
- if (SCOORDGroup) {
5830
- return this.getMeasurementDataFromScoord({
5831
- defaultState,
5832
- SCOORDGroup,
5833
- imageToWorldCoords,
5834
- NUMGroup,
5835
- ReferencedFrameNumber
5836
- });
5837
- } else if (SCOORD3DGroup) {
5838
- return this.getMeasurementDataFromScoord3D({
5839
- SCOORD3DGroup,
5840
- defaultState
5841
- });
5842
- } else {
5843
- throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
5844
- }
5845
- }
5846
- static getMeasurementDataFromScoord(_ref) {
5847
- let {
5848
- defaultState,
5849
- SCOORDGroup,
5850
- imageToWorldCoords,
5851
- NUMGroup,
5458
+ state,
5459
+ worldCoords,
5460
+ referencedImageId,
5852
5461
  ReferencedFrameNumber
5853
- } = _ref;
5854
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
5855
- const {
5856
- GraphicData
5857
- } = SCOORDGroup;
5858
- const worldCoords = [];
5859
- for (let i = 0; i < GraphicData.length; i += 2) {
5860
- const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
5861
- worldCoords.push(point);
5862
- }
5863
- const state = defaultState;
5462
+ } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
5463
+ const areaGroup = MeasurementGroup.ContentSequence.find(g => g.ValueType === "NUM" && g.ConceptNameCodeSequence[0].CodeMeaning === "Area");
5464
+ const cachedStats = referencedImageId ? {
5465
+ [`imageId:${referencedImageId}`]: {
5466
+ area: areaGroup?.MeasuredValueSequence?.[0]?.NumericValue || 0,
5467
+ areaUnit: areaGroup?.MeasuredValueSequence?.[0]?.MeasurementUnitsCodeSequence?.CodeValue
5468
+ }
5469
+ } : {};
5864
5470
  state.annotation.data = {
5471
+ ...state.annotation.data,
5865
5472
  handles: {
5866
- points: [worldCoords[0], worldCoords[1], worldCoords[3], worldCoords[2]],
5867
- activeHandleIndex: 0,
5868
- textBox: {
5869
- hasMoved: false
5870
- }
5871
- },
5872
- cachedStats: {
5873
- [`imageId:${referencedImageId}`]: {
5874
- area: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : null
5875
- }
5473
+ ...state.annotation.data.handles,
5474
+ points: [worldCoords[0], worldCoords[1], worldCoords[3], worldCoords[2]]
5876
5475
  },
5476
+ cachedStats,
5877
5477
  frameNumber: ReferencedFrameNumber
5878
5478
  };
5879
5479
  return state;
5880
5480
  }
5881
- static getMeasurementDataFromScoord3D(_ref2) {
5882
- let {
5883
- SCOORD3DGroup,
5884
- defaultState
5885
- } = _ref2;
5886
- const {
5887
- GraphicData
5888
- } = SCOORD3DGroup;
5889
- const worldCoords = [];
5890
- for (let i = 0; i < GraphicData.length; i += 3) {
5891
- const point = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
5892
- worldCoords.push(point);
5893
- }
5894
- const state = defaultState;
5895
- state.annotation.data = {
5896
- handles: {
5897
- points: [worldCoords[0], worldCoords[1], worldCoords[3], worldCoords[2]],
5898
- activeHandleIndex: 0,
5899
- textBox: {
5900
- hasMoved: false
5901
- }
5902
- },
5903
- cachedStats: {}
5904
- };
5905
- return state;
5906
- }
5907
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
5481
+ static getTID300RepresentationArguments(tool) {
5482
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
5908
5483
  const {
5909
5484
  data,
5910
5485
  finding,
5911
5486
  findingSites,
5912
5487
  metadata
5913
5488
  } = tool;
5914
- const {
5915
- cachedStats = {},
5916
- handles
5917
- } = data;
5918
5489
  const {
5919
5490
  referencedImageId
5920
5491
  } = metadata;
5921
- if (!referencedImageId) {
5922
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
5923
- }
5924
- const corners = handles.points.map(point => worldToImageCoords(referencedImageId, point));
5925
- const {
5926
- area,
5927
- perimeter
5928
- } = cachedStats;
5929
- return {
5930
- points: [corners[0], corners[1], corners[3], corners[2], corners[0]],
5931
- area,
5932
- perimeter,
5933
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
5934
- finding,
5935
- findingSites: findingSites || [],
5936
- use3DSpatialCoordinates: false
5492
+ const scoordProps = {
5493
+ is3DMeasurement,
5494
+ referencedImageId
5937
5495
  };
5938
- }
5939
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
5940
- const {
5941
- data,
5942
- finding,
5943
- findingSites,
5944
- metadata
5945
- } = tool;
5946
- const {
5947
- cachedStats = {},
5948
- handles
5949
- } = data;
5950
- const corners = handles.points;
5496
+ const corners = toScoords(scoordProps, data.handles.points);
5951
5497
  const {
5952
5498
  area,
5953
5499
  perimeter
5954
- } = cachedStats;
5500
+ } = data.cachedStats[`imageId:${referencedImageId}`] || {};
5955
5501
  return {
5956
5502
  points: [corners[0], corners[1], corners[3], corners[2], corners[0]],
5957
5503
  area,
@@ -5959,8 +5505,7 @@ class RectangleROI extends BaseAdapter3D {
5959
5505
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
5960
5506
  finding,
5961
5507
  findingSites: findingSites || [],
5962
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
5963
- use3DSpatialCoordinates: true
5508
+ use3DSpatialCoordinates: is3DMeasurement
5964
5509
  };
5965
5510
  }
5966
5511
  }
@@ -5977,95 +5522,42 @@ _RectangleROI = RectangleROI;
5977
5522
 
5978
5523
 
5979
5524
 
5525
+
5526
+
5527
+
5980
5528
  var _Length;
5981
5529
  const {
5982
5530
  Length: Length_TID300Length
5983
5531
  } = dcmjs_es/* utilities */.BF.TID300;
5984
5532
  const Length_LENGTH = "Length";
5985
5533
  class Length_Length extends BaseAdapter3D {
5986
- static getMeasurementDataFromScoord(_ref) {
5987
- let {
5988
- defaultState,
5989
- NUMGroup,
5990
- SCOORDGroup,
5991
- ReferencedFrameNumber,
5992
- imageToWorldCoords
5993
- } = _ref;
5994
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
5534
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
5995
5535
  const {
5996
- GraphicData
5997
- } = SCOORDGroup;
5998
- const worldCoords = [];
5999
- for (let i = 0; i < GraphicData.length; i += 2) {
6000
- const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
6001
- worldCoords.push(point);
6002
- }
6003
- const state = defaultState;
5536
+ state,
5537
+ NUMGroup,
5538
+ worldCoords,
5539
+ referencedImageId,
5540
+ ReferencedFrameNumber
5541
+ } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
5542
+ const cachedStats = referencedImageId ? {
5543
+ [`imageId:${referencedImageId}`]: {
5544
+ length: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : 0
5545
+ }
5546
+ } : {};
6004
5547
  state.annotation.data = {
5548
+ ...state.annotation.data,
6005
5549
  handles: {
5550
+ ...state.annotation.data.handles,
6006
5551
  points: [worldCoords[0], worldCoords[1]],
6007
- activeHandleIndex: 0,
6008
- textBox: {
6009
- hasMoved: false
6010
- }
6011
- },
6012
- cachedStats: {
6013
- [`imageId:${referencedImageId}`]: {
6014
- length: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : 0
6015
- }
5552
+ activeHandleIndex: 0
6016
5553
  },
5554
+ cachedStats,
6017
5555
  frameNumber: ReferencedFrameNumber
6018
5556
  };
6019
5557
  return state;
6020
5558
  }
6021
- static getMeasurementDataFromScoord3d(_ref2) {
6022
- let {
6023
- defaultState,
6024
- SCOORD3DGroup
6025
- } = _ref2;
6026
- const {
6027
- GraphicData
6028
- } = SCOORD3DGroup;
6029
- const worldCoords = GraphicData;
6030
- const state = defaultState;
6031
- state.annotation.data = {
6032
- handles: {
6033
- points: [worldCoords.slice(0, 3), worldCoords.slice(3, 6)],
6034
- activeHandleIndex: 0,
6035
- textBox: {
6036
- hasMoved: false
6037
- }
6038
- },
6039
- cachedStats: {}
6040
- };
6041
- return state;
6042
- }
6043
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
6044
- const {
6045
- defaultState,
6046
- NUMGroup,
6047
- SCOORDGroup,
6048
- SCOORD3DGroup,
6049
- ReferencedFrameNumber
6050
- } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
6051
- if (SCOORDGroup) {
6052
- return this.getMeasurementDataFromScoord({
6053
- defaultState,
6054
- NUMGroup,
6055
- SCOORDGroup,
6056
- ReferencedFrameNumber,
6057
- imageToWorldCoords
6058
- });
6059
- } else if (SCOORD3DGroup) {
6060
- return this.getMeasurementDataFromScoord3d({
6061
- defaultState,
6062
- SCOORD3DGroup
6063
- });
6064
- } else {
6065
- throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
6066
- }
6067
- }
6068
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
5559
+ static getTID300RepresentationArguments(tool) {
5560
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6069
5561
  const {
6070
5562
  data,
6071
5563
  finding,
@@ -6079,19 +5571,12 @@ class Length_Length extends BaseAdapter3D {
6079
5571
  const {
6080
5572
  referencedImageId
6081
5573
  } = metadata;
6082
- if (!referencedImageId) {
6083
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
6084
- }
6085
- const start = worldToImageCoords(referencedImageId, handles.points[0]);
6086
- const end = worldToImageCoords(referencedImageId, handles.points[1]);
6087
- const point1 = {
6088
- x: start[0],
6089
- y: start[1]
6090
- };
6091
- const point2 = {
6092
- x: end[0],
6093
- y: end[1]
5574
+ const scoordProps = {
5575
+ is3DMeasurement,
5576
+ referencedImageId
6094
5577
  };
5578
+ const point1 = toScoord(scoordProps, handles.points[0]);
5579
+ const point2 = toScoord(scoordProps, handles.points[1]);
6095
5580
  const {
6096
5581
  length: distance
6097
5582
  } = cachedStats[`imageId:${referencedImageId}`] || {};
@@ -6102,45 +5587,7 @@ class Length_Length extends BaseAdapter3D {
6102
5587
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
6103
5588
  finding,
6104
5589
  findingSites: findingSites || [],
6105
- use3DSpatialCoordinates: false
6106
- };
6107
- }
6108
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
6109
- const {
6110
- data,
6111
- finding,
6112
- findingSites,
6113
- metadata
6114
- } = tool;
6115
- const {
6116
- cachedStats = {},
6117
- handles
6118
- } = data;
6119
- const start = handles.points[0];
6120
- const end = handles.points[1];
6121
- const point1 = {
6122
- x: start[0],
6123
- y: start[1],
6124
- z: start[2]
6125
- };
6126
- const point2 = {
6127
- x: end[0],
6128
- y: end[1],
6129
- z: end[2]
6130
- };
6131
- const cachedStatsKeys = Object.keys(cachedStats)[0];
6132
- const {
6133
- length: distance = undefined
6134
- } = cachedStatsKeys ? cachedStats[cachedStatsKeys] : {};
6135
- return {
6136
- point1,
6137
- point2,
6138
- distance,
6139
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
6140
- finding,
6141
- findingSites: findingSites || [],
6142
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
6143
- use3DSpatialCoordinates: true
5590
+ use3DSpatialCoordinates: is3DMeasurement
6144
5591
  };
6145
5592
  }
6146
5593
  }
@@ -6152,104 +5599,30 @@ _Length = Length_Length;
6152
5599
 
6153
5600
 
6154
5601
 
5602
+ // EXTERNAL MODULE: ../../../node_modules/gl-matrix/esm/index.js + 1 modules
5603
+ var gl_matrix_esm = __webpack_require__(3823);
6155
5604
  ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/adapters/Cornerstone3D/PlanarFreehandROI.js
6156
5605
 
6157
5606
 
6158
5607
 
6159
5608
 
6160
5609
 
5610
+
5611
+
5612
+
6161
5613
  var _PlanarFreehandROI;
6162
5614
  const {
6163
5615
  Polyline: PlanarFreehandROI_TID300Polyline
6164
5616
  } = dcmjs_es/* utilities */.BF.TID300;
6165
5617
  class PlanarFreehandROI extends BaseAdapter3D {
6166
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
5618
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata) {
6167
5619
  const {
6168
- defaultState,
6169
- NUMGroup,
6170
- SCOORDGroup,
6171
- SCOORD3DGroup,
6172
- ReferencedFrameNumber
6173
- } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, PlanarFreehandROI.toolType);
6174
- if (SCOORDGroup) {
6175
- return this.getMeasurementDataFromScoord({
6176
- defaultState,
6177
- SCOORDGroup,
6178
- imageToWorldCoords,
6179
- NUMGroup,
6180
- ReferencedFrameNumber
6181
- });
6182
- } else if (SCOORD3DGroup) {
6183
- return this.getMeasurementDataFromScoord3D({
6184
- defaultState,
6185
- SCOORD3DGroup
6186
- });
6187
- } else {
6188
- throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
6189
- }
6190
- }
6191
- static getMeasurementDataFromScoord(_ref) {
6192
- let {
6193
- defaultState,
6194
- SCOORDGroup,
6195
- imageToWorldCoords,
5620
+ state,
6196
5621
  NUMGroup,
5622
+ worldCoords,
5623
+ referencedImageId,
6197
5624
  ReferencedFrameNumber
6198
- } = _ref;
6199
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
6200
- const {
6201
- GraphicData
6202
- } = SCOORDGroup;
6203
- const worldCoords = [];
6204
- for (let i = 0; i < GraphicData.length; i += 2) {
6205
- const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
6206
- worldCoords.push(point);
6207
- }
6208
- const distanceBetweenFirstAndLastPoint = gl_matrix_esm/* vec3.distance */.eR.distance(worldCoords[worldCoords.length - 1], worldCoords[0]);
6209
- let isOpenContour = true;
6210
- if (distanceBetweenFirstAndLastPoint < this.closedContourThreshold) {
6211
- worldCoords.pop();
6212
- isOpenContour = false;
6213
- }
6214
- const points = [];
6215
- if (isOpenContour) {
6216
- points.push(worldCoords[0], worldCoords[worldCoords.length - 1]);
6217
- }
6218
- const state = defaultState;
6219
- state.annotation.data = {
6220
- contour: {
6221
- polyline: worldCoords,
6222
- closed: !isOpenContour
6223
- },
6224
- handles: {
6225
- points,
6226
- activeHandleIndex: null,
6227
- textBox: {
6228
- hasMoved: false
6229
- }
6230
- },
6231
- cachedStats: {
6232
- [`imageId:${referencedImageId}`]: {
6233
- area: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : null
6234
- }
6235
- },
6236
- frameNumber: ReferencedFrameNumber
6237
- };
6238
- return state;
6239
- }
6240
- static getMeasurementDataFromScoord3D(_ref2) {
6241
- let {
6242
- defaultState,
6243
- SCOORD3DGroup
6244
- } = _ref2;
6245
- const {
6246
- GraphicData
6247
- } = SCOORD3DGroup;
6248
- const worldCoords = [];
6249
- for (let i = 0; i < GraphicData.length; i += 3) {
6250
- const point = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
6251
- worldCoords.push(point);
6252
- }
5625
+ } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
6253
5626
  const distanceBetweenFirstAndLastPoint = gl_matrix_esm/* vec3.distance */.eR.distance(worldCoords[worldCoords.length - 1], worldCoords[0]);
6254
5627
  let isOpenContour = true;
6255
5628
  if (distanceBetweenFirstAndLastPoint < this.closedContourThreshold) {
@@ -6260,24 +5633,29 @@ class PlanarFreehandROI extends BaseAdapter3D {
6260
5633
  if (isOpenContour) {
6261
5634
  points.push(worldCoords[0], worldCoords[worldCoords.length - 1]);
6262
5635
  }
6263
- const state = defaultState;
6264
5636
  state.annotation.data = {
5637
+ ...state.annotation.data,
6265
5638
  contour: {
6266
5639
  polyline: worldCoords,
6267
5640
  closed: !isOpenContour
6268
5641
  },
6269
5642
  handles: {
6270
- points,
6271
- activeHandleIndex: null,
6272
- textBox: {
6273
- hasMoved: false
6274
- }
5643
+ ...state.annotation.data.handles,
5644
+ points
6275
5645
  },
6276
- cachedStats: {}
5646
+ frameNumber: ReferencedFrameNumber
6277
5647
  };
5648
+ if (referencedImageId) {
5649
+ state.annotation.data.cachedStats = {
5650
+ [`imageId:${referencedImageId}`]: {
5651
+ area: NUMGroup ? NUMGroup.MeasuredValueSequence.NumericValue : null
5652
+ }
5653
+ };
5654
+ }
6278
5655
  return state;
6279
5656
  }
6280
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
5657
+ static getTID300RepresentationArguments(tool) {
5658
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6281
5659
  const {
6282
5660
  data,
6283
5661
  finding,
@@ -6292,13 +5670,14 @@ class PlanarFreehandROI extends BaseAdapter3D {
6292
5670
  const {
6293
5671
  referencedImageId
6294
5672
  } = metadata;
6295
- if (!referencedImageId) {
6296
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
6297
- }
6298
- const points = polyline.map(worldPos => worldToImageCoords(referencedImageId, worldPos));
5673
+ const scoordProps = {
5674
+ is3DMeasurement,
5675
+ referencedImageId
5676
+ };
5677
+ const points = toScoords(scoordProps, polyline);
6299
5678
  if (!isOpenContour) {
6300
5679
  const firstPoint = points[0];
6301
- points.push([firstPoint[0], firstPoint[1]]);
5680
+ points.push(firstPoint);
6302
5681
  }
6303
5682
  const {
6304
5683
  area,
@@ -6321,50 +5700,8 @@ class PlanarFreehandROI extends BaseAdapter3D {
6321
5700
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
6322
5701
  finding,
6323
5702
  findingSites: findingSites || [],
6324
- use3DSpatialCoordinates: false
6325
- };
6326
- }
6327
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
6328
- const {
6329
- data,
6330
- finding,
6331
- findingSites,
6332
- metadata
6333
- } = tool;
6334
- const {
6335
- polyline,
6336
- closed
6337
- } = data.contour;
6338
- const isOpenContour = closed !== true;
6339
- const points = polyline;
6340
- if (!isOpenContour) {
6341
- const firstPoint = points[0];
6342
- points.push([firstPoint[0], firstPoint[1], firstPoint[2]]);
6343
- }
6344
- const cachedStatsKeys = Object.keys(data.cachedStats)[0];
6345
- const {
6346
- area = undefined,
6347
- areaUnit = undefined,
6348
- modalityUnit = undefined,
6349
- perimeter = undefined,
6350
- mean = undefined,
6351
- max = undefined,
6352
- stdDev = undefined
6353
- } = cachedStatsKeys ? data.cachedStats[cachedStatsKeys] : {};
6354
- return {
6355
- points,
6356
- area,
6357
- areaUnit,
6358
- perimeter,
6359
- modalityUnit,
6360
- mean,
6361
- max,
6362
- stdDev,
6363
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
6364
- finding,
6365
- findingSites: findingSites || [],
6366
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
6367
- use3DSpatialCoordinates: true
5703
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
5704
+ use3DSpatialCoordinates: is3DMeasurement
6368
5705
  };
6369
5706
  }
6370
5707
  }
@@ -6379,88 +5716,45 @@ _PlanarFreehandROI.init("PlanarFreehandROI", PlanarFreehandROI_TID300Polyline);
6379
5716
 
6380
5717
 
6381
5718
 
5719
+
5720
+
5721
+
6382
5722
  var _Probe;
6383
5723
  const {
6384
5724
  Point: Probe_TID300Point
6385
5725
  } = dcmjs_es/* utilities */.BF.TID300;
6386
5726
  class Probe extends BaseAdapter3D {
6387
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata, trackingIdentifier) {
6388
- const state = super.getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata, trackingIdentifier);
6389
- const {
6390
- defaultState,
6391
- SCOORDGroup,
6392
- SCOORD3DGroup
6393
- } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, Probe.toolType);
6394
- if (SCOORDGroup) {
6395
- return this.getMeasurementDataFromScoord({
6396
- state,
6397
- defaultState,
6398
- SCOORDGroup,
6399
- imageToWorldCoords
6400
- });
6401
- } else if (SCOORD3DGroup) {
6402
- return this.getMeasurementDataFromScoord3D({
6403
- state,
6404
- SCOORD3DGroup
6405
- });
6406
- } else {
6407
- throw new Error("Can't get measurement data with missing SCOORD and SCOORD3D groups.");
6408
- }
5727
+ static isValidMeasurement(measurement) {
5728
+ const graphicItem = this.getGraphicItem(measurement);
5729
+ return this.getGraphicType(graphicItem) === "POINT" && this.getPointsCount(graphicItem) <= 2;
6409
5730
  }
6410
- static getMeasurementDataFromScoord(_ref) {
6411
- let {
6412
- state,
6413
- defaultState,
6414
- SCOORDGroup,
6415
- imageToWorldCoords
6416
- } = _ref;
6417
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
5731
+ static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, _trackingIdentifier) {
6418
5732
  const {
6419
- GraphicData
6420
- } = SCOORDGroup;
6421
- const worldCoords = [];
6422
- for (let i = 0; i < GraphicData.length; i += 2) {
6423
- const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
6424
- worldCoords.push(point);
6425
- }
6426
- state.annotation.data = {
6427
- ...state.annotation.data,
6428
- handles: {
6429
- points: worldCoords,
6430
- activeHandleIndex: null,
6431
- textBox: {
6432
- hasMoved: false
6433
- }
6434
- }
6435
- };
6436
- return state;
6437
- }
6438
- static getMeasurementDataFromScoord3D(_ref2) {
6439
- let {
6440
5733
  state,
6441
- SCOORD3DGroup
6442
- } = _ref2;
6443
- const {
6444
- GraphicData
6445
- } = SCOORD3DGroup;
6446
- const worldCoords = [];
6447
- for (let i = 0; i < GraphicData.length; i += 3) {
6448
- const point = [GraphicData[i], GraphicData[i + 1], GraphicData[i + 2]];
6449
- worldCoords.push(point);
6450
- }
5734
+ NUMGroup,
5735
+ worldCoords,
5736
+ referencedImageId,
5737
+ ReferencedFrameNumber
5738
+ } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
5739
+ const cachedStats = referencedImageId ? {
5740
+ [`imageId:${referencedImageId}`]: {
5741
+ value: NUMGroup?.MeasuredValueSequence?.NumericValue ?? null
5742
+ }
5743
+ } : {};
6451
5744
  state.annotation.data = {
6452
5745
  ...state.annotation.data,
6453
5746
  handles: {
6454
- points: worldCoords,
6455
- activeHandleIndex: null,
6456
- textBox: {
6457
- hasMoved: false
6458
- }
6459
- }
5747
+ ...state.annotation.data.handles,
5748
+ points: worldCoords
5749
+ },
5750
+ cachedStats,
5751
+ frameNumber: ReferencedFrameNumber,
5752
+ invalidated: true
6460
5753
  };
6461
5754
  return state;
6462
5755
  }
6463
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
5756
+ static getTID300RepresentationArguments(tool) {
5757
+ let is3DMeasurement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
6464
5758
  const {
6465
5759
  data,
6466
5760
  metadata
@@ -6472,54 +5766,23 @@ class Probe extends BaseAdapter3D {
6472
5766
  const {
6473
5767
  referencedImageId
6474
5768
  } = metadata;
6475
- if (!referencedImageId) {
6476
- return this.getTID300RepresentationArgumentsSCOORD3D(tool);
6477
- }
6478
- const {
6479
- handles: {
6480
- points = []
6481
- }
6482
- } = data;
6483
- const pointsImage = points.map(point => {
6484
- const pointImage = worldToImageCoords(referencedImageId, point);
6485
- return {
6486
- x: pointImage[0],
6487
- y: pointImage[1]
6488
- };
6489
- });
6490
- return {
6491
- points: pointsImage,
6492
- trackingIdentifierTextValue: this.trackingIdentifierTextValue,
6493
- findingSites: findingSites || [],
6494
- finding,
6495
- use3DSpatialCoordinates: false
5769
+ const scoordProps = {
5770
+ is3DMeasurement,
5771
+ referencedImageId
6496
5772
  };
6497
- }
6498
- static getTID300RepresentationArgumentsSCOORD3D(tool) {
6499
- const {
6500
- data,
6501
- finding,
6502
- findingSites,
6503
- metadata
6504
- } = tool;
6505
5773
  const {
6506
5774
  handles: {
6507
5775
  points = []
6508
5776
  }
6509
5777
  } = data;
6510
- const point = points[0];
6511
- const pointXYZ = {
6512
- x: point[0],
6513
- y: point[1],
6514
- z: point[2]
6515
- };
5778
+ const pointsImage = toScoords(scoordProps, points);
6516
5779
  return {
6517
- points: [pointXYZ],
5780
+ points: pointsImage,
6518
5781
  trackingIdentifierTextValue: this.trackingIdentifierTextValue,
6519
- ReferencedFrameOfReferenceUID: metadata.FrameOfReferenceUID,
6520
5782
  findingSites: findingSites || [],
6521
5783
  finding,
6522
- use3DSpatialCoordinates: true
5784
+ ReferencedFrameOfReferenceUID: is3DMeasurement ? metadata.FrameOfReferenceUID : null,
5785
+ use3DSpatialCoordinates: is3DMeasurement
6523
5786
  };
6524
5787
  }
6525
5788
  }
@@ -6527,6 +5790,8 @@ _Probe = Probe;
6527
5790
  (() => {
6528
5791
  _Probe.init("Probe", Probe_TID300Point);
6529
5792
  _Probe.registerLegacy();
5793
+ _Probe.registerType("DCM:111030", "POINT", 1);
5794
+ _Probe.registerType("DCM:111030", "POINT", 2);
6530
5795
  })();
6531
5796
 
6532
5797
 
@@ -6536,41 +5801,32 @@ _Probe = Probe;
6536
5801
 
6537
5802
 
6538
5803
 
5804
+
6539
5805
  var _UltrasoundDirectional;
6540
5806
  const {
6541
5807
  Length: UltrasoundDirectional_TID300Length
6542
5808
  } = dcmjs_es/* utilities */.BF.TID300;
5809
+ const {
5810
+ worldToImageCoords
5811
+ } = esm.utilities;
6543
5812
  class UltrasoundDirectional extends BaseAdapter3D {
6544
- static getMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata) {
5813
+ static getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, metadata) {
6545
5814
  const {
6546
- defaultState,
6547
- SCOORDGroup,
5815
+ state,
5816
+ worldCoords,
6548
5817
  ReferencedFrameNumber
6549
- } = MeasurementReport_MeasurementReport.getSetupMeasurementData(MeasurementGroup, sopInstanceUIDToImageIdMap, metadata, UltrasoundDirectional.toolType);
6550
- const referencedImageId = defaultState.annotation.metadata.referencedImageId;
6551
- const {
6552
- GraphicData
6553
- } = SCOORDGroup;
6554
- const worldCoords = [];
6555
- for (let i = 0; i < GraphicData.length; i += 2) {
6556
- const point = imageToWorldCoords(referencedImageId, [GraphicData[i], GraphicData[i + 1]]);
6557
- worldCoords.push(point);
6558
- }
6559
- const state = defaultState;
5818
+ } = MeasurementReport_MeasurementReport.getSetupMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, metadata, this.toolType);
6560
5819
  state.annotation.data = {
5820
+ ...state.annotation.data,
6561
5821
  handles: {
6562
- points: [worldCoords[0], worldCoords[1]],
6563
- activeHandleIndex: 0,
6564
- textBox: {
6565
- hasMoved: false
6566
- }
5822
+ ...state.annotation.data.handles,
5823
+ points: worldCoords
6567
5824
  },
6568
- cachedStats: {},
6569
5825
  frameNumber: ReferencedFrameNumber
6570
5826
  };
6571
5827
  return state;
6572
5828
  }
6573
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
5829
+ static getTID300RepresentationArguments(tool, is3DMeasurement) {
6574
5830
  const {
6575
5831
  data,
6576
5832
  finding,
@@ -7706,16 +6962,16 @@ const {
7706
6962
  Point: KeyImage_TID300Point
7707
6963
  } = dcmjs_es/* utilities */.BF.TID300;
7708
6964
  class KeyImage extends Probe {
7709
- static getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata, trackingIdentifier) {
7710
- const baseData = super.getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata, trackingIdentifier);
6965
+ static getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, metadata, trackingIdentifier) {
6966
+ const baseData = super.getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, metadata, trackingIdentifier);
7711
6967
  const {
7712
6968
  data
7713
6969
  } = baseData.annotation;
7714
6970
  data.isPoint = trackingIdentifier.indexOf("Point") !== -1;
7715
6971
  return baseData;
7716
6972
  }
7717
- static getTID300RepresentationArguments(tool, worldToImageCoords) {
7718
- const tid300Arguments = super.getTID300RepresentationArguments(tool, worldToImageCoords);
6973
+ static getTID300RepresentationArguments(tool) {
6974
+ const tid300Arguments = super.getTID300RepresentationArguments(tool);
7719
6975
  const {
7720
6976
  data
7721
6977
  } = tool;
@@ -7768,6 +7024,7 @@ _KeyImage.trackingSeriesPointIdentifier = `${_KeyImage.trackingIdentifierTextVal
7768
7024
 
7769
7025
 
7770
7026
 
7027
+
7771
7028
 
7772
7029
  const Cornerstone3DSR = {
7773
7030
  BaseAdapter3D: BaseAdapter3D,
@@ -7785,7 +7042,10 @@ const Cornerstone3DSR = {
7785
7042
  KeyImage: KeyImage,
7786
7043
  MeasurementReport: MeasurementReport_MeasurementReport,
7787
7044
  CodeScheme: CodingScheme,
7788
- CORNERSTONE_3D_TAG: CORNERSTONE_3D_TAG
7045
+ CORNERSTONE_3D_TAG: CORNERSTONE_3D_TAG,
7046
+ COMMENT_CODE: COMMENT_CODE,
7047
+ NO_IMAGE_ID: NO_IMAGE_ID,
7048
+ TEXT_ANNOTATION_POSITION: TEXT_ANNOTATION_POSITION
7789
7049
  };
7790
7050
  const Cornerstone3DSEG = {
7791
7051
  Segmentation: Cornerstone3D_Segmentation_namespaceObject
@@ -7998,6 +7258,7 @@ const VTKjsSEG = {
7998
7258
 
7999
7259
 
8000
7260
 
7261
+
8001
7262
  const adaptersSR = {
8002
7263
  Cornerstone: CornerstoneSR,
8003
7264
  Cornerstone3D: Cornerstone3DSR
@@ -8067,127 +7328,16 @@ function downloadDICOMData(bufferOrDataset, filename) {
8067
7328
 
8068
7329
 
8069
7330
 
8070
- ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/index.js
8071
-
8072
-
8073
-
8074
-
8075
-
8076
-
8077
-
8078
-
8079
- /***/ }),
8080
-
8081
- /***/ 49892:
8082
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8083
-
8084
- "use strict";
8085
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8086
- /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
8087
- /* harmony export */ });
8088
- var ToolModes;
8089
- (function (ToolModes) {
8090
- ToolModes["Active"] = "Active";
8091
- ToolModes["Passive"] = "Passive";
8092
- ToolModes["Enabled"] = "Enabled";
8093
- ToolModes["Disabled"] = "Disabled";
8094
- })(ToolModes || (ToolModes = {}));
8095
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ToolModes);
8096
-
8097
-
8098
- /***/ }),
8099
-
8100
- /***/ 66452:
8101
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8102
-
8103
- "use strict";
8104
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8105
- /* harmony export */ i: () => (/* binding */ MouseBindings),
8106
- /* harmony export */ q: () => (/* binding */ KeyboardBindings)
8107
- /* harmony export */ });
8108
- var MouseBindings;
8109
- (function (MouseBindings) {
8110
- MouseBindings[MouseBindings["Primary"] = 1] = "Primary";
8111
- MouseBindings[MouseBindings["Secondary"] = 2] = "Secondary";
8112
- MouseBindings[MouseBindings["Primary_And_Secondary"] = 3] = "Primary_And_Secondary";
8113
- MouseBindings[MouseBindings["Auxiliary"] = 4] = "Auxiliary";
8114
- MouseBindings[MouseBindings["Primary_And_Auxiliary"] = 5] = "Primary_And_Auxiliary";
8115
- MouseBindings[MouseBindings["Secondary_And_Auxiliary"] = 6] = "Secondary_And_Auxiliary";
8116
- MouseBindings[MouseBindings["Primary_And_Secondary_And_Auxiliary"] = 7] = "Primary_And_Secondary_And_Auxiliary";
8117
- MouseBindings[MouseBindings["Fourth_Button"] = 8] = "Fourth_Button";
8118
- MouseBindings[MouseBindings["Fifth_Button"] = 16] = "Fifth_Button";
8119
- MouseBindings[MouseBindings["Wheel"] = 524288] = "Wheel";
8120
- MouseBindings[MouseBindings["Wheel_Primary"] = 524289] = "Wheel_Primary";
8121
- })(MouseBindings || (MouseBindings = {}));
8122
- var KeyboardBindings;
8123
- (function (KeyboardBindings) {
8124
- KeyboardBindings[KeyboardBindings["Shift"] = 16] = "Shift";
8125
- KeyboardBindings[KeyboardBindings["Ctrl"] = 17] = "Ctrl";
8126
- KeyboardBindings[KeyboardBindings["Alt"] = 18] = "Alt";
8127
- KeyboardBindings[KeyboardBindings["Meta"] = 91] = "Meta";
8128
- KeyboardBindings[KeyboardBindings["ShiftCtrl"] = 1617] = "ShiftCtrl";
8129
- KeyboardBindings[KeyboardBindings["ShiftAlt"] = 1618] = "ShiftAlt";
8130
- KeyboardBindings[KeyboardBindings["ShiftMeta"] = 1691] = "ShiftMeta";
8131
- KeyboardBindings[KeyboardBindings["CtrlAlt"] = 1718] = "CtrlAlt";
8132
- KeyboardBindings[KeyboardBindings["CtrlMeta"] = 1791] = "CtrlMeta";
8133
- KeyboardBindings[KeyboardBindings["AltMeta"] = 1891] = "AltMeta";
8134
- })(KeyboardBindings || (KeyboardBindings = {}));
8135
7331
 
8136
7332
 
8137
7333
 
8138
- /***/ }),
7334
+ ;// ../../../node_modules/@cornerstonejs/adapters/dist/esm/index.js
8139
7335
 
8140
- /***/ 75183:
8141
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8142
7336
 
8143
- "use strict";
8144
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8145
- /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
8146
- /* harmony export */ });
8147
- var ChangeTypes;
8148
- (function (ChangeTypes) {
8149
- ChangeTypes["Interaction"] = "Interaction";
8150
- ChangeTypes["HandlesUpdated"] = "HandlesUpdated";
8151
- ChangeTypes["StatsUpdated"] = "StatsUpdated";
8152
- ChangeTypes["InitialSetup"] = "InitialSetup";
8153
- ChangeTypes["Completed"] = "Completed";
8154
- ChangeTypes["InterpolationUpdated"] = "InterpolationUpdated";
8155
- ChangeTypes["History"] = "History";
8156
- ChangeTypes["MetadataReferenceModified"] = "MetadataReferenceModified";
8157
- ChangeTypes["LabelChange"] = "LabelChange";
8158
- })(ChangeTypes || (ChangeTypes = {}));
8159
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ChangeTypes);
8160
7337
 
8161
7338
 
8162
- /***/ }),
8163
7339
 
8164
- /***/ 84093:
8165
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8166
7340
 
8167
- "use strict";
8168
- /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8169
- /* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
8170
- /* harmony export */ });
8171
- var StrategyCallbacks;
8172
- (function (StrategyCallbacks) {
8173
- StrategyCallbacks["OnInteractionStart"] = "onInteractionStart";
8174
- StrategyCallbacks["OnInteractionEnd"] = "onInteractionEnd";
8175
- StrategyCallbacks["Preview"] = "preview";
8176
- StrategyCallbacks["RejectPreview"] = "rejectPreview";
8177
- StrategyCallbacks["AcceptPreview"] = "acceptPreview";
8178
- StrategyCallbacks["Fill"] = "fill";
8179
- StrategyCallbacks["Interpolate"] = "interpolate";
8180
- StrategyCallbacks["StrategyFunction"] = "strategyFunction";
8181
- StrategyCallbacks["CreateIsInThreshold"] = "createIsInThreshold";
8182
- StrategyCallbacks["Initialize"] = "initialize";
8183
- StrategyCallbacks["INTERNAL_setValue"] = "setValue";
8184
- StrategyCallbacks["AddPreview"] = "addPreview";
8185
- StrategyCallbacks["ComputeInnerCircleRadius"] = "computeInnerCircleRadius";
8186
- StrategyCallbacks["GetStatistics"] = "getStatistics";
8187
- StrategyCallbacks["EnsureImageVolumeFor3DManipulation"] = "ensureImageVolumeFor3DManipulation";
8188
- StrategyCallbacks["EnsureSegmentationVolumeFor3DManipulation"] = "ensureSegmentationVolumeFor3DManipulation";
8189
- })(StrategyCallbacks || (StrategyCallbacks = {}));
8190
- /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (StrategyCallbacks);
8191
7341
 
8192
7342
 
8193
7343
  /***/ }),
@@ -8206,6 +7356,8 @@ var Events;
8206
7356
  Events["TOOLGROUP_VIEWPORT_REMOVED"] = "CORNERSTONE_TOOLS_TOOLGROUP_VIEWPORT_REMOVED";
8207
7357
  Events["TOOL_MODE_CHANGED"] = "CORNERSTONE_TOOLS_TOOL_MODE_CHANGED";
8208
7358
  Events["CROSSHAIR_TOOL_CENTER_CHANGED"] = "CORNERSTONE_TOOLS_CROSSHAIR_TOOL_CENTER_CHANGED";
7359
+ Events["VOLUMECROPPINGCONTROL_TOOL_CHANGED"] = "CORNERSTONE_TOOLS_VOLUMECROPPINGCONTROL_TOOL_CHANGED";
7360
+ Events["VOLUMECROPPING_TOOL_CHANGED"] = "CORNERSTONE_TOOLS_VOLUMECROPPING_TOOL_CHANGED";
8209
7361
  Events["ANNOTATION_ADDED"] = "CORNERSTONE_TOOLS_ANNOTATION_ADDED";
8210
7362
  Events["ANNOTATION_COMPLETED"] = "CORNERSTONE_TOOLS_ANNOTATION_COMPLETED";
8211
7363
  Events["ANNOTATION_MODIFIED"] = "CORNERSTONE_TOOLS_ANNOTATION_MODIFIED";