@cornerstonejs/tools 1.77.6 → 1.77.8

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 (21) hide show
  1. package/dist/cjs/tools/annotation/EllipticalROITool.js +49 -57
  2. package/dist/cjs/tools/annotation/EllipticalROITool.js.map +1 -1
  3. package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +8 -1
  4. package/dist/cjs/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
  5. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js +8 -1
  6. package/dist/cjs/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
  7. package/dist/esm/tools/annotation/EllipticalROITool.js +49 -57
  8. package/dist/esm/tools/annotation/EllipticalROITool.js.map +1 -1
  9. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js +7 -1
  10. package/dist/esm/tools/annotation/planarFreehandROITool/closedContourEditLoop.js.map +1 -1
  11. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js +7 -1
  12. package/dist/esm/tools/annotation/planarFreehandROITool/openContourEditLoop.js.map +1 -1
  13. package/dist/types/tools/annotation/EllipticalROITool.d.ts.map +1 -1
  14. package/dist/types/tools/annotation/planarFreehandROITool/closedContourEditLoop.d.ts.map +1 -1
  15. package/dist/types/tools/annotation/planarFreehandROITool/openContourEditLoop.d.ts.map +1 -1
  16. package/dist/umd/index.js +1 -1
  17. package/dist/umd/index.js.map +1 -1
  18. package/package.json +3 -3
  19. package/src/tools/annotation/EllipticalROITool.ts +75 -80
  20. package/src/tools/annotation/planarFreehandROITool/closedContourEditLoop.ts +9 -1
  21. package/src/tools/annotation/planarFreehandROITool/openContourEditLoop.ts +9 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "1.77.6",
3
+ "version": "1.77.8",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
30
30
  },
31
31
  "dependencies": {
32
- "@cornerstonejs/core": "^1.77.6",
32
+ "@cornerstonejs/core": "^1.77.8",
33
33
  "@icr/polyseg-wasm": "0.4.0",
34
34
  "@types/offscreencanvas": "2019.7.3",
35
35
  "comlink": "^4.4.1",
@@ -59,5 +59,5 @@
59
59
  "type": "individual",
60
60
  "url": "https://ohif.org/donate"
61
61
  },
62
- "gitHead": "584c4c7faf635983064722bc1999eb081d839c67"
62
+ "gitHead": "1e097cfe0063b0593395cd6610c4feb64ff97d38"
63
63
  }
@@ -770,7 +770,6 @@ class EllipticalROITool extends AnnotationTool {
770
770
  );
771
771
 
772
772
  const { centerPointRadius } = this.configuration;
773
-
774
773
  // If cachedStats does not exist, or the unit is missing (as part of import/hydration etc.),
775
774
  // force to recalculate the stats from the points
776
775
  if (
@@ -1012,99 +1011,95 @@ class EllipticalROITool extends AnnotationTool {
1012
1011
  // Check if one of the indexes are inside the volume, this then gives us
1013
1012
  // Some area to do stats over.
1014
1013
 
1015
- if (this._isInsideVolume(pos1Index, post2Index, dimensions)) {
1016
- this.isHandleOutsideImage = false;
1014
+ this.isHandleOutsideImage = !this._isInsideVolume(
1015
+ pos1Index,
1016
+ post2Index,
1017
+ dimensions
1018
+ );
1017
1019
 
1018
- const iMin = Math.min(pos1Index[0], post2Index[0]);
1019
- const iMax = Math.max(pos1Index[0], post2Index[0]);
1020
+ const iMin = Math.min(pos1Index[0], post2Index[0]);
1021
+ const iMax = Math.max(pos1Index[0], post2Index[0]);
1020
1022
 
1021
- const jMin = Math.min(pos1Index[1], post2Index[1]);
1022
- const jMax = Math.max(pos1Index[1], post2Index[1]);
1023
+ const jMin = Math.min(pos1Index[1], post2Index[1]);
1024
+ const jMax = Math.max(pos1Index[1], post2Index[1]);
1023
1025
 
1024
- const kMin = Math.min(pos1Index[2], post2Index[2]);
1025
- const kMax = Math.max(pos1Index[2], post2Index[2]);
1026
+ const kMin = Math.min(pos1Index[2], post2Index[2]);
1027
+ const kMax = Math.max(pos1Index[2], post2Index[2]);
1026
1028
 
1027
- const boundsIJK = [
1028
- [iMin, iMax],
1029
- [jMin, jMax],
1030
- [kMin, kMax],
1031
- ] as [Types.Point2, Types.Point2, Types.Point2];
1029
+ const boundsIJK = [
1030
+ [iMin, iMax],
1031
+ [jMin, jMax],
1032
+ [kMin, kMax],
1033
+ ] as [Types.Point2, Types.Point2, Types.Point2];
1032
1034
 
1033
- const center = [
1034
- (topLeftWorld[0] + bottomRightWorld[0]) / 2,
1035
- (topLeftWorld[1] + bottomRightWorld[1]) / 2,
1036
- (topLeftWorld[2] + bottomRightWorld[2]) / 2,
1037
- ] as Types.Point3;
1035
+ const center = [
1036
+ (topLeftWorld[0] + bottomRightWorld[0]) / 2,
1037
+ (topLeftWorld[1] + bottomRightWorld[1]) / 2,
1038
+ (topLeftWorld[2] + bottomRightWorld[2]) / 2,
1039
+ ] as Types.Point3;
1038
1040
 
1039
- const ellipseObj = {
1040
- center,
1041
- xRadius: Math.abs(topLeftWorld[0] - bottomRightWorld[0]) / 2,
1042
- yRadius: Math.abs(topLeftWorld[1] - bottomRightWorld[1]) / 2,
1043
- zRadius: Math.abs(topLeftWorld[2] - bottomRightWorld[2]) / 2,
1044
- };
1045
-
1046
- const { worldWidth, worldHeight } = getWorldWidthAndHeightFromTwoPoints(
1047
- viewPlaneNormal,
1048
- viewUp,
1049
- worldPos1,
1050
- worldPos2
1051
- );
1052
- const isEmptyArea = worldWidth === 0 && worldHeight === 0;
1041
+ const ellipseObj = {
1042
+ center,
1043
+ xRadius: Math.abs(topLeftWorld[0] - bottomRightWorld[0]) / 2,
1044
+ yRadius: Math.abs(topLeftWorld[1] - bottomRightWorld[1]) / 2,
1045
+ zRadius: Math.abs(topLeftWorld[2] - bottomRightWorld[2]) / 2,
1046
+ };
1053
1047
 
1054
- const handles = [pos1Index, post2Index];
1055
- const { scale, areaUnits } = getCalibratedLengthUnitsAndScale(
1056
- image,
1057
- handles
1058
- );
1048
+ const { worldWidth, worldHeight } = getWorldWidthAndHeightFromTwoPoints(
1049
+ viewPlaneNormal,
1050
+ viewUp,
1051
+ worldPos1,
1052
+ worldPos2
1053
+ );
1054
+ const isEmptyArea = worldWidth === 0 && worldHeight === 0;
1059
1055
 
1060
- const area =
1061
- Math.abs(Math.PI * (worldWidth / 2) * (worldHeight / 2)) /
1062
- scale /
1063
- scale;
1056
+ const handles = [pos1Index, post2Index];
1057
+ const { scale, areaUnits } = getCalibratedLengthUnitsAndScale(
1058
+ image,
1059
+ handles
1060
+ );
1064
1061
 
1065
- const modalityUnitOptions = {
1066
- isPreScaled: isViewportPreScaled(viewport, targetId),
1062
+ const area =
1063
+ Math.abs(Math.PI * (worldWidth / 2) * (worldHeight / 2)) /
1064
+ scale /
1065
+ scale;
1067
1066
 
1068
- isSuvScaled: this.isSuvScaled(
1069
- viewport,
1070
- targetId,
1071
- annotation.metadata.referencedImageId
1072
- ),
1073
- };
1067
+ const modalityUnitOptions = {
1068
+ isPreScaled: isViewportPreScaled(viewport, targetId),
1074
1069
 
1075
- const modalityUnit = getModalityUnit(
1076
- metadata.Modality,
1077
- annotation.metadata.referencedImageId,
1078
- modalityUnitOptions
1079
- );
1070
+ isSuvScaled: this.isSuvScaled(
1071
+ viewport,
1072
+ targetId,
1073
+ annotation.metadata.referencedImageId
1074
+ ),
1075
+ };
1080
1076
 
1081
- const pointsInShape = pointInShapeCallback(
1082
- imageData,
1083
- (pointLPS) => pointInEllipse(ellipseObj, pointLPS, { fast: true }),
1084
- this.configuration.statsCalculator.statsCallback,
1085
- boundsIJK
1086
- );
1077
+ const modalityUnit = getModalityUnit(
1078
+ metadata.Modality,
1079
+ annotation.metadata.referencedImageId,
1080
+ modalityUnitOptions
1081
+ );
1087
1082
 
1088
- const stats = this.configuration.statsCalculator.getStatistics();
1089
- cachedStats[targetId] = {
1090
- Modality: metadata.Modality,
1091
- area,
1092
- mean: stats.mean?.value,
1093
- max: stats.max?.value,
1094
- stdDev: stats.stdDev?.value,
1095
- statsArray: stats.array,
1096
- pointsInShape,
1097
- isEmptyArea,
1098
- areaUnit: areaUnits,
1099
- modalityUnit,
1100
- };
1101
- } else {
1102
- this.isHandleOutsideImage = true;
1083
+ const pointsInShape = pointInShapeCallback(
1084
+ imageData,
1085
+ (pointLPS) => pointInEllipse(ellipseObj, pointLPS, { fast: true }),
1086
+ this.configuration.statsCalculator.statsCallback,
1087
+ boundsIJK
1088
+ );
1103
1089
 
1104
- cachedStats[targetId] = {
1105
- Modality: metadata.Modality,
1106
- };
1107
- }
1090
+ const stats = this.configuration.statsCalculator.getStatistics();
1091
+ cachedStats[targetId] = {
1092
+ Modality: metadata.Modality,
1093
+ area,
1094
+ mean: stats.mean?.value,
1095
+ max: stats.max?.value,
1096
+ stdDev: stats.stdDev?.value,
1097
+ statsArray: stats.array,
1098
+ pointsInShape,
1099
+ isEmptyArea,
1100
+ areaUnit: areaUnits,
1101
+ modalityUnit,
1102
+ };
1108
1103
  }
1109
1104
 
1110
1105
  annotation.invalidated = false;
@@ -452,6 +452,8 @@ function completeClosedContourEdit(element: HTMLDivElement) {
452
452
  )
453
453
  : fusedCanvasPoints;
454
454
 
455
+ const decimateConfig = this.configuration?.decimate || {};
456
+
455
457
  updateContourPolyline(
456
458
  annotation,
457
459
  {
@@ -459,7 +461,13 @@ function completeClosedContourEdit(element: HTMLDivElement) {
459
461
  closed: true,
460
462
  targetWindingDirection: ContourWindingDirection.Clockwise,
461
463
  },
462
- viewport
464
+ viewport,
465
+ {
466
+ decimate: {
467
+ enabled: !!decimateConfig.enabled,
468
+ epsilon: decimateConfig.epsilon,
469
+ },
470
+ }
463
471
  );
464
472
 
465
473
  // If any manual update, triggered on an annotation, then it will be treated as non-autogenerated.
@@ -562,13 +562,21 @@ function completeOpenContourEdit(element: HTMLDivElement) {
562
562
  )
563
563
  : fusedCanvasPoints;
564
564
 
565
+ const decimateConfig = this.configuration?.decimate || {};
566
+
565
567
  updateContourPolyline(
566
568
  annotation,
567
569
  {
568
570
  points: updatedPoints,
569
571
  closed: false,
570
572
  },
571
- viewport
573
+ viewport,
574
+ {
575
+ decimate: {
576
+ enabled: !!decimateConfig.enabled,
577
+ epsilon: decimateConfig.epsilon,
578
+ },
579
+ }
572
580
  );
573
581
 
574
582
  const worldPoints = annotation.data.contour.polyline;