@cornerstonejs/tools 3.14.3 → 3.15.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.
@@ -1,4 +1,4 @@
1
- import { CONSTANTS, getEnabledElement, VolumeViewport, utilities as csUtils, } from '@cornerstonejs/core';
1
+ import { CONSTANTS, getEnabledElement, VolumeViewport, utilities as csUtils, metaData, } from '@cornerstonejs/core';
2
2
  import { vec3 } from 'gl-matrix';
3
3
  import { getCalibratedLengthUnitsAndScale } from '../../utilities/getCalibratedUnits';
4
4
  import * as math from '../../utilities/math';
@@ -260,7 +260,30 @@ class PlanarFreehandROITool extends ContourSegmentationBaseTool {
260
260
  filterAnnotationsWithinSlice(annotations, camera, spacingInNormalDirection) {
261
261
  const { viewPlaneNormal } = camera;
262
262
  const annotationsWithParallelNormals = annotations.filter((td) => {
263
- const annotationViewPlaneNormal = td.metadata.viewPlaneNormal;
263
+ let annotationViewPlaneNormal = td.metadata.viewPlaneNormal;
264
+ if (!td.metadata.referencedImageId &&
265
+ !annotationViewPlaneNormal &&
266
+ td.metadata.FrameOfReferenceUID) {
267
+ for (const point of td.data.contour.polyline) {
268
+ const vector = vec3.sub(vec3.create(), point, camera.focalPoint);
269
+ const dotProduct = vec3.dot(vector, camera.viewPlaneNormal);
270
+ if (!csUtils.isEqual(dotProduct, 0)) {
271
+ return false;
272
+ }
273
+ }
274
+ td.metadata.viewPlaneNormal = camera.viewPlaneNormal;
275
+ td.metadata.cameraFocalPoint = camera.focalPoint;
276
+ return true;
277
+ }
278
+ if (!annotationViewPlaneNormal) {
279
+ const { referencedImageId } = td.metadata;
280
+ const { imageOrientationPatient } = metaData.get('imagePlaneModule', referencedImageId);
281
+ const rowCosineVec = vec3.fromValues(imageOrientationPatient[0], imageOrientationPatient[1], imageOrientationPatient[2]);
282
+ const colCosineVec = vec3.fromValues(imageOrientationPatient[3], imageOrientationPatient[4], imageOrientationPatient[5]);
283
+ annotationViewPlaneNormal = vec3.create();
284
+ vec3.cross(annotationViewPlaneNormal, rowCosineVec, colCosineVec);
285
+ td.metadata.viewPlaneNormal = annotationViewPlaneNormal;
286
+ }
264
287
  const isParallel = Math.abs(vec3.dot(viewPlaneNormal, annotationViewPlaneNormal)) >
265
288
  PARALLEL_THRESHOLD;
266
289
  return annotationViewPlaneNormal && isParallel;
@@ -45,6 +45,11 @@ declare abstract class AnnotationTool extends AnnotationDisplayTool {
45
45
  handles?: import("../../types/AnnotationTypes").Handles;
46
46
  cachedStats?: Record<string, unknown>;
47
47
  label?: string;
48
+ contour?: {
49
+ polyline?: Types.Point3[];
50
+ pointsManager?: Types.IPointsManager<Types.Point3>;
51
+ closed?: boolean;
52
+ };
48
53
  };
49
54
  deleting: boolean;
50
55
  };
@@ -20,8 +20,14 @@ type Annotation = {
20
20
  [key: string]: unknown;
21
21
  cachedStats?: Record<string, unknown>;
22
22
  label?: string;
23
+ contour?: Contour;
23
24
  };
24
25
  };
26
+ type Contour = {
27
+ polyline?: Types.Point3[];
28
+ pointsManager?: Types.IPointsManager<Types.Point3>;
29
+ closed?: boolean;
30
+ };
25
31
  type Annotations = Array<Annotation>;
26
32
  type GroupSpecificAnnotations = {
27
33
  [toolName: string]: Annotations;
@@ -1,11 +1,26 @@
1
1
  import { vec3 } from 'gl-matrix';
2
- import { CONSTANTS, metaData } from '@cornerstonejs/core';
2
+ import { CONSTANTS, metaData, utilities } from '@cornerstonejs/core';
3
+ const { isEqual } = utilities;
3
4
  const { EPSILON } = CONSTANTS;
4
5
  const PARALLEL_THRESHOLD = 1 - EPSILON;
5
6
  export default function filterAnnotationsWithinSlice(annotations, camera, spacingInNormalDirection) {
6
7
  const { viewPlaneNormal } = camera;
7
8
  const annotationsWithParallelNormals = annotations.filter((td) => {
8
9
  let annotationViewPlaneNormal = td.metadata.viewPlaneNormal;
10
+ if (!td.metadata.referencedImageId &&
11
+ !annotationViewPlaneNormal &&
12
+ td.metadata.FrameOfReferenceUID) {
13
+ for (const point of td.data.handles.points) {
14
+ const vector = vec3.sub(vec3.create(), point, camera.focalPoint);
15
+ const dotProduct = vec3.dot(vector, camera.viewPlaneNormal);
16
+ if (!isEqual(dotProduct, 0)) {
17
+ return false;
18
+ }
19
+ }
20
+ td.metadata.viewPlaneNormal = camera.viewPlaneNormal;
21
+ td.metadata.cameraFocalPoint = camera.focalPoint;
22
+ return true;
23
+ }
9
24
  if (!annotationViewPlaneNormal) {
10
25
  const { referencedImageId } = td.metadata;
11
26
  const { imageOrientationPatient } = metaData.get('imagePlaneModule', referencedImageId);
@@ -44,7 +44,7 @@ function volumetricGetStatistics(state, stats, options) {
44
44
  calibration,
45
45
  hasPixelSpacing: true,
46
46
  }, []);
47
- const volumeScale = spacing ? spacing[0] * spacing[1] * spacing[2] * 1000 : 1;
47
+ const volumeScale = spacing ? spacing[0] * spacing[1] * spacing[2] : 1;
48
48
  stats.volume = {
49
49
  value: Array.isArray(stats.count.value)
50
50
  ? stats.count.value.map((v) => v * volumeScale)
@@ -1 +1 @@
1
- export declare const version = "3.14.3";
1
+ export declare const version = "3.15.0";
@@ -1 +1 @@
1
- export const version = '3.14.3';
1
+ export const version = '3.15.0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "3.14.3",
3
+ "version": "3.15.0",
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.14.3",
111
+ "@cornerstonejs/core": "^3.15.0",
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": "902ff8c03f0bb19963532fcf6286155ecbdd2d98"
130
+ "gitHead": "77edfa9761d0f7dcf841386dd453dca9fbc83ca9"
131
131
  }