@cornerstonejs/tools 5.0.0 → 5.0.2

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.
@@ -35,11 +35,12 @@ declare class PlanarFreehandROITool extends ContourSegmentationBaseTool {
35
35
  protected renderAnnotationInstance(renderContext: AnnotationRenderContext): boolean;
36
36
  _calculateStatsIfActive(annotation: PlanarFreehandROIAnnotation, targetId: string, viewport: any, renderingEngine: any, enabledElement: any): void;
37
37
  private _calculateCachedStats;
38
- protected updateClosedCachedStats({ viewport, points, imageData, metadata, cachedStats, targetId, modalityUnit, canvasCoordinates, calibratedScale, deltaInX, deltaInY, }: {
38
+ protected updateClosedCachedStats({ viewport, points, imageData, metadata, voxelManager, cachedStats, targetId, modalityUnit, canvasCoordinates, calibratedScale, deltaInX, deltaInY, }: {
39
39
  viewport: any;
40
40
  points: any;
41
41
  imageData: any;
42
42
  metadata: any;
43
+ voxelManager: any;
43
44
  cachedStats: any;
44
45
  targetId: any;
45
46
  modalityUnit: any;
@@ -20,6 +20,7 @@ import { BasicStatsCalculator } from '../../utilities/math/basic';
20
20
  import ContourSegmentationBaseTool from '../base/ContourSegmentationBaseTool';
21
21
  import { KeyboardBindings, ChangeTypes, MeasurementType } from '../../enums';
22
22
  import { getPixelValueUnits } from '../../utilities/getPixelValueUnits';
23
+ import snapIndexBounds from '../../utilities/boundingBox/snapIndexBounds';
23
24
  const { pointCanProjectOnLine } = polyline;
24
25
  const { EPSILON } = CONSTANTS;
25
26
  const PARALLEL_THRESHOLD = 1 - EPSILON;
@@ -139,7 +140,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
139
140
  if (!image) {
140
141
  continue;
141
142
  }
142
- const { imageData, metadata } = image;
143
+ const { imageData, metadata, voxelManager } = image;
143
144
  const canvasCoordinates = points.map((p) => viewport.worldToCanvas(p));
144
145
  const modalityUnitOptions = {
145
146
  isPreScaled: isViewportPreScaled(viewport, targetId),
@@ -181,6 +182,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
181
182
  points,
182
183
  imageData,
183
184
  metadata,
185
+ voxelManager,
184
186
  cachedStats,
185
187
  modalityUnit,
186
188
  calibratedScale,
@@ -407,9 +409,8 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
407
409
  }
408
410
  }
409
411
  }
410
- updateClosedCachedStats({ viewport, points, imageData, metadata, cachedStats, targetId, modalityUnit, canvasCoordinates, calibratedScale, deltaInX, deltaInY, }) {
412
+ updateClosedCachedStats({ viewport, points, imageData, metadata, voxelManager, cachedStats, targetId, modalityUnit, canvasCoordinates, calibratedScale, deltaInX, deltaInY, }) {
411
413
  const { areaUnit, unit } = calibratedScale;
412
- const { voxelManager } = viewport.getImageData();
413
414
  const indexPoints = points.map((point) => imageData.worldToIndex(point));
414
415
  let iMin = Number.MAX_SAFE_INTEGER;
415
416
  let iMax = Number.MIN_SAFE_INTEGER;
@@ -418,7 +419,7 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
418
419
  let kMin = Number.MAX_SAFE_INTEGER;
419
420
  let kMax = Number.MIN_SAFE_INTEGER;
420
421
  for (let j = 0; j < points.length; j++) {
421
- const worldPosIndex = indexPoints[j].map(Math.floor);
422
+ const worldPosIndex = indexPoints[j];
422
423
  iMin = Math.min(iMin, worldPosIndex[0]);
423
424
  iMax = Math.max(iMax, worldPosIndex[0]);
424
425
  jMin = Math.min(jMin, worldPosIndex[1]);
@@ -426,6 +427,9 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
426
427
  kMin = Math.min(kMin, worldPosIndex[2]);
427
428
  kMax = Math.max(kMax, worldPosIndex[2]);
428
429
  }
430
+ [iMin, iMax] = snapIndexBounds(iMin, iMax);
431
+ [jMin, jMax] = snapIndexBounds(jMin, jMax);
432
+ [kMin, kMax] = snapIndexBounds(kMin, kMax);
429
433
  const area = polyline.getArea(canvasCoordinates) * deltaInX * deltaInY;
430
434
  const perimeter = PlanarFreehandROITool.calculateLengthInIndex(calibratedScale, indexPoints, closed);
431
435
  const iDelta = 0.01 * (iMax - iMin);
@@ -1,3 +1,4 @@
1
1
  import extend2DBoundingBoxInViewAxis from './extend2DBoundingBoxInViewAxis';
2
2
  import { getBoundingBoxAroundShapeIJK, getBoundingBoxAroundShapeWorld } from './getBoundingBoxAroundShape';
3
- export { extend2DBoundingBoxInViewAxis, getBoundingBoxAroundShapeIJK, getBoundingBoxAroundShapeWorld, getBoundingBoxAroundShapeIJK as getBoundingBoxAroundShape, };
3
+ import snapIndexBounds from './snapIndexBounds';
4
+ export { extend2DBoundingBoxInViewAxis, getBoundingBoxAroundShapeIJK, getBoundingBoxAroundShapeWorld, snapIndexBounds, getBoundingBoxAroundShapeIJK as getBoundingBoxAroundShape, };
@@ -1,3 +1,4 @@
1
1
  import extend2DBoundingBoxInViewAxis from './extend2DBoundingBoxInViewAxis';
2
2
  import { getBoundingBoxAroundShapeIJK, getBoundingBoxAroundShapeWorld, } from './getBoundingBoxAroundShape';
3
- export { extend2DBoundingBoxInViewAxis, getBoundingBoxAroundShapeIJK, getBoundingBoxAroundShapeWorld, getBoundingBoxAroundShapeIJK as getBoundingBoxAroundShape, };
3
+ import snapIndexBounds from './snapIndexBounds';
4
+ export { extend2DBoundingBoxInViewAxis, getBoundingBoxAroundShapeIJK, getBoundingBoxAroundShapeWorld, snapIndexBounds, getBoundingBoxAroundShapeIJK as getBoundingBoxAroundShape, };
@@ -0,0 +1,3 @@
1
+ import type { Types } from '@cornerstonejs/core';
2
+ declare function snapIndexBounds(min: number, max: number): Types.Point2;
3
+ export default snapIndexBounds;
@@ -0,0 +1,9 @@
1
+ function snapIndexBounds(min, max) {
2
+ const delta = max - min;
3
+ if (delta <= 1) {
4
+ const index = Math.round((min + max) / 2);
5
+ return [index, index];
6
+ }
7
+ return [Math.floor(min), Math.ceil(max)];
8
+ }
9
+ export default snapIndexBounds;
@@ -1 +1 @@
1
- export declare const version = "5.0.0";
1
+ export declare const version = "5.0.2";
@@ -1 +1 @@
1
- export const version = '5.0.0';
1
+ export const version = '5.0.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -84,6 +84,9 @@
84
84
  "types": "./dist/esm/version.d.ts"
85
85
  }
86
86
  },
87
+ "publishConfig": {
88
+ "access": "public"
89
+ },
87
90
  "scripts": {
88
91
  "prebuild": "node ../../scripts/generate-version.js ./",
89
92
  "build:esm": "pnpm run prebuild && tsc --project ./tsconfig.json",
@@ -105,11 +108,11 @@
105
108
  "lodash.get": "4.4.2"
106
109
  },
107
110
  "devDependencies": {
108
- "@cornerstonejs/core": "5.0.0",
111
+ "@cornerstonejs/core": "5.0.2",
109
112
  "canvas": "3.2.0"
110
113
  },
111
114
  "peerDependencies": {
112
- "@cornerstonejs/core": "5.0.0",
115
+ "@cornerstonejs/core": "5.0.2",
113
116
  "@kitware/vtk.js": "35.5.3",
114
117
  "@types/d3-array": "3.2.1",
115
118
  "@types/d3-interpolate": "3.0.4",
@@ -128,5 +131,5 @@
128
131
  "type": "individual",
129
132
  "url": "https://ohif.org/donate"
130
133
  },
131
- "gitHead": "d6f3fba43abcbaaf7468ff534588f6a88720b875"
134
+ "gitHead": "b1f35afb1ff6a75fc487ecabf71fec4851d7d339"
132
135
  }