@cornerstonejs/tools 3.15.5 → 3.15.6

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.
@@ -18,6 +18,7 @@ import triggerAnnotationRenderForViewportIds from '../../utilities/triggerAnnota
18
18
  import { getPixelValueUnits } from '../../utilities/getPixelValueUnits';
19
19
  import { isViewportPreScaled } from '../../utilities/viewport/isViewportPreScaled';
20
20
  import { BasicStatsCalculator } from '../../utilities/math/basic';
21
+ import { vec2 } from 'gl-matrix';
21
22
  const { transformWorldToIndex } = csUtils;
22
23
  class EllipticalROITool extends AnnotationTool {
23
24
  static { this.toolName = 'EllipticalROI'; }
@@ -104,19 +105,22 @@ class EllipticalROITool extends AnnotationTool {
104
105
  const { data } = annotation;
105
106
  const { points } = data.handles;
106
107
  const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
107
- const canvasCorners = getCanvasEllipseCorners(canvasCoordinates);
108
- const [canvasPoint1, canvasPoint2] = canvasCorners;
108
+ const [bottom, top, left, right] = canvasCoordinates;
109
+ const w = Math.hypot(left[0] - right[0], left[1] - right[1]);
110
+ const h = Math.hypot(top[0] - bottom[0], top[1] - bottom[1]);
111
+ const angle = Math.atan2(left[1] - right[1], left[0] - right[0]);
112
+ const center = [(left[0] + right[0]) / 2, (top[1] + bottom[1]) / 2];
109
113
  const minorEllipse = {
110
- left: Math.min(canvasPoint1[0], canvasPoint2[0]) + proximity / 2,
111
- top: Math.min(canvasPoint1[1], canvasPoint2[1]) + proximity / 2,
112
- width: Math.abs(canvasPoint1[0] - canvasPoint2[0]) - proximity,
113
- height: Math.abs(canvasPoint1[1] - canvasPoint2[1]) - proximity,
114
+ center,
115
+ xRadius: (w - proximity) / 2,
116
+ yRadius: (h - proximity) / 2,
117
+ angle,
114
118
  };
115
119
  const majorEllipse = {
116
- left: Math.min(canvasPoint1[0], canvasPoint2[0]) - proximity / 2,
117
- top: Math.min(canvasPoint1[1], canvasPoint2[1]) - proximity / 2,
118
- width: Math.abs(canvasPoint1[0] - canvasPoint2[0]) + proximity,
119
- height: Math.abs(canvasPoint1[1] - canvasPoint2[1]) + proximity,
120
+ center,
121
+ xRadius: (w + proximity) / 2,
122
+ yRadius: (h + proximity) / 2,
123
+ angle,
120
124
  };
121
125
  const pointInMinorEllipse = this._pointInEllipseCanvas(minorEllipse, canvasCoords);
122
126
  const pointInMajorEllipse = this._pointInEllipseCanvas(majorEllipse, canvasCoords);
@@ -672,13 +676,12 @@ class EllipticalROITool extends AnnotationTool {
672
676
  triggerAnnotationRenderForViewportIds([viewport.id]);
673
677
  }; }
674
678
  _pointInEllipseCanvas(ellipse, location) {
675
- const xRadius = ellipse.width / 2;
676
- const yRadius = ellipse.height / 2;
679
+ const { xRadius, yRadius, center, angle } = ellipse;
680
+ const rotLocation = vec2.rotate(vec2.create(), location, center, -angle);
677
681
  if (xRadius <= 0.0 || yRadius <= 0.0) {
678
682
  return false;
679
683
  }
680
- const center = [ellipse.left + xRadius, ellipse.top + yRadius];
681
- const normalized = [location[0] - center[0], location[1] - center[1]];
684
+ const normalized = [rotLocation[0] - center[0], rotLocation[1] - center[1]];
682
685
  const inEllipse = (normalized[0] * normalized[0]) / (xRadius * xRadius) +
683
686
  (normalized[1] * normalized[1]) / (yRadius * yRadius) <=
684
687
  1.0;
@@ -1 +1 @@
1
- export declare const version = "3.15.5";
1
+ export declare const version = "3.15.6";
@@ -1 +1 @@
1
- export const version = '3.15.5';
1
+ export const version = '3.15.6';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "3.15.5",
3
+ "version": "3.15.6",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -108,7 +108,7 @@
108
108
  "canvas": "^3.1.0"
109
109
  },
110
110
  "peerDependencies": {
111
- "@cornerstonejs/core": "^3.15.5",
111
+ "@cornerstonejs/core": "^3.15.6",
112
112
  "@kitware/vtk.js": "32.12.1",
113
113
  "@types/d3-array": "^3.0.4",
114
114
  "@types/d3-interpolate": "^3.0.1",
@@ -127,5 +127,5 @@
127
127
  "type": "individual",
128
128
  "url": "https://ohif.org/donate"
129
129
  },
130
- "gitHead": "54b78585158c51f11dd6b312f08bcf56b148d4f1"
130
+ "gitHead": "c529e179b3e8aaa9e21d628d35c6f745419c0cf0"
131
131
  }