@cornerstonejs/core 3.9.0 → 3.9.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.
|
@@ -1651,7 +1651,7 @@ class StackViewport extends Viewport {
|
|
|
1651
1651
|
const imageIds = this.getImageIds();
|
|
1652
1652
|
const imageData = this.getImageData();
|
|
1653
1653
|
const { direction, spacing } = imageData;
|
|
1654
|
-
const imageId = getClosestImageId({ direction
|
|
1654
|
+
const imageId = getClosestImageId({ direction, spacing, imageIds }, worldPos, this.getCamera().viewPlaneNormal, { ignoreSpacing: true });
|
|
1655
1655
|
const index = imageIds.indexOf(imageId);
|
|
1656
1656
|
if (index === -1) {
|
|
1657
1657
|
return false;
|
|
@@ -4,4 +4,6 @@ export default function getClosestImageId(imageVolume: IImageVolume | {
|
|
|
4
4
|
direction: mat3;
|
|
5
5
|
spacing: Point3;
|
|
6
6
|
imageIds: string[];
|
|
7
|
-
}, worldPos: Point3, viewPlaneNormal: Point3
|
|
7
|
+
}, worldPos: Point3, viewPlaneNormal: Point3, options?: {
|
|
8
|
+
ignoreSpacing?: boolean;
|
|
9
|
+
}): string | undefined;
|
|
@@ -2,28 +2,51 @@ import { vec3 } from 'gl-matrix';
|
|
|
2
2
|
import * as metaData from '../metaData';
|
|
3
3
|
import getSpacingInNormalDirection from './getSpacingInNormalDirection';
|
|
4
4
|
import { EPSILON } from '../constants';
|
|
5
|
-
export default function getClosestImageId(imageVolume, worldPos, viewPlaneNormal) {
|
|
5
|
+
export default function getClosestImageId(imageVolume, worldPos, viewPlaneNormal, options) {
|
|
6
6
|
const { direction, spacing, imageIds } = imageVolume;
|
|
7
|
-
|
|
7
|
+
const { ignoreSpacing = false } = options || {};
|
|
8
|
+
if (!imageIds?.length) {
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
11
|
const kVector = direction.slice(6, 9);
|
|
11
|
-
const
|
|
12
|
-
if (Math.abs(
|
|
12
|
+
const dotProduct = vec3.dot(kVector, viewPlaneNormal);
|
|
13
|
+
if (Math.abs(dotProduct) < 1 - EPSILON) {
|
|
14
|
+
console.debug('View plane normal is not parallel to the image scan axis. Unable to find closest imageId.');
|
|
13
15
|
return;
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
let halfSpacingInNormalDirection;
|
|
18
|
+
if (!ignoreSpacing) {
|
|
19
|
+
const spacingInNormalDirection = getSpacingInNormalDirection({ direction, spacing }, viewPlaneNormal);
|
|
20
|
+
halfSpacingInNormalDirection = spacingInNormalDirection / 2;
|
|
21
|
+
}
|
|
22
|
+
let closestImageId;
|
|
23
|
+
let minDistance = Infinity;
|
|
18
24
|
for (let i = 0; i < imageIds.length; i++) {
|
|
19
25
|
const imageId = imageIds[i];
|
|
20
|
-
const
|
|
26
|
+
const imagePlaneModule = metaData.get('imagePlaneModule', imageId);
|
|
27
|
+
if (!imagePlaneModule?.imagePositionPatient) {
|
|
28
|
+
console.warn(`Missing imagePositionPatient for imageId: ${imageId}`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const { imagePositionPatient } = imagePlaneModule;
|
|
21
32
|
const dir = vec3.create();
|
|
22
33
|
vec3.sub(dir, worldPos, imagePositionPatient);
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
25
|
-
|
|
34
|
+
const distance = Math.abs(vec3.dot(dir, viewPlaneNormal));
|
|
35
|
+
if (ignoreSpacing) {
|
|
36
|
+
if (distance < minDistance) {
|
|
37
|
+
minDistance = distance;
|
|
38
|
+
closestImageId = imageId;
|
|
39
|
+
}
|
|
26
40
|
}
|
|
41
|
+
else {
|
|
42
|
+
if (distance < halfSpacingInNormalDirection && distance < minDistance) {
|
|
43
|
+
minDistance = distance;
|
|
44
|
+
closestImageId = imageId;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (closestImageId === undefined) {
|
|
49
|
+
console.debug('No imageId found within the specified criteria (half spacing or absolute closest).');
|
|
27
50
|
}
|
|
28
|
-
return
|
|
51
|
+
return closestImageId;
|
|
29
52
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.2",
|
|
4
4
|
"description": "Cornerstone3D Core",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"types": "./dist/esm/index.d.ts",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"type": "individual",
|
|
92
92
|
"url": "https://ohif.org/donate"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "7fdba50da86956a4c35e45dbdc21ab3b8decea72"
|
|
95
95
|
}
|