@cornerstonejs/core 1.14.2 → 1.14.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "1.14.2",
3
+ "version": "1.14.4",
4
4
  "description": "",
5
5
  "main": "dist/umd/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -46,5 +46,5 @@
46
46
  "type": "individual",
47
47
  "url": "https://ohif.org/donate"
48
48
  },
49
- "gitHead": "7fb460c47629f6694a78c6bed836b432e1af13a3"
49
+ "gitHead": "96dc1772a2f77a7626c07e19434b42753e9d4188"
50
50
  }
@@ -1,9 +1,15 @@
1
1
  import { vec3, mat4 } from 'gl-matrix';
2
2
  import { IStackViewport } from '../types';
3
- import { StackViewport } from '../RenderingEngine';
4
3
  import spatialRegistrationMetadataProvider from './spatialRegistrationMetadataProvider';
5
4
  import { metaData } from '..';
6
- import isEqual from './isEqual';
5
+
6
+ /**
7
+ * Defines the allowed difference as a percent between the unit normals before
8
+ * two planes are considered not coplanar. Since this value is small compared
9
+ * to the unit lenght, this value is approximately the angular difference, measured
10
+ * in radians. That is, allow about a 3 degrees variation.
11
+ */
12
+ const ALLOWED_DELTA = 0.05;
7
13
 
8
14
  /**
9
15
  * It calculates the registration matrix between two viewports (currently only
@@ -21,40 +27,28 @@ function calculateViewportsSpatialRegistration(
21
27
  viewport1: IStackViewport,
22
28
  viewport2: IStackViewport
23
29
  ): void {
24
- if (
25
- !(viewport1 instanceof StackViewport) ||
26
- !(viewport2 instanceof StackViewport)
27
- ) {
28
- throw new Error(
29
- 'calculateViewportsSpatialRegistration: Both viewports must be StackViewports, volume viewports are not supported yet'
30
- );
31
- }
32
-
33
- const isSameFrameOfReference =
34
- viewport1.getFrameOfReferenceUID() === viewport2.getFrameOfReferenceUID();
35
-
36
- if (isSameFrameOfReference) {
37
- return;
38
- }
39
-
40
30
  const imageId1 = viewport1.getCurrentImageId();
41
31
  const imageId2 = viewport2.getCurrentImageId();
42
32
 
43
33
  const imagePlaneModule1 = metaData.get('imagePlaneModule', imageId1);
44
34
  const imagePlaneModule2 = metaData.get('imagePlaneModule', imageId2);
45
35
 
46
- const isSameImagePlane =
47
- imagePlaneModule1 &&
48
- imagePlaneModule2 &&
49
- isEqual(
50
- imagePlaneModule1.imageOrientationPatient,
51
- imagePlaneModule2.imageOrientationPatient
52
- );
36
+ if (!imagePlaneModule1 || !imagePlaneModule2) {
37
+ console.log('Viewport spatial registration requires image plane module');
38
+ return;
39
+ }
40
+ const { imageOrientationPatient: iop2 } = imagePlaneModule2;
41
+ const isSameImagePlane = imagePlaneModule1.imageOrientationPatient.every(
42
+ (v, i) => Math.abs(v - iop2[i]) < ALLOWED_DELTA
43
+ );
53
44
 
54
45
  if (!isSameImagePlane) {
55
- throw new Error(
56
- 'Viewport spatial registration only supported for same orientation (hence translation only) for now'
46
+ console.log(
47
+ 'Viewport spatial registration only supported for same orientation (hence translation only) for now',
48
+ imagePlaneModule1?.imageOrientationPatient,
49
+ imagePlaneModule2?.imageOrientationPatient
57
50
  );
51
+ return;
58
52
  }
59
53
 
60
54
  const imagePositionPatient1 = imagePlaneModule1.imagePositionPatient;
@@ -67,7 +61,6 @@ function calculateViewportsSpatialRegistration(
67
61
  );
68
62
 
69
63
  const mat = mat4.fromTranslation(mat4.create(), translation);
70
-
71
64
  spatialRegistrationMetadataProvider.add([viewport1.id, viewport2.id], mat);
72
65
  }
73
66