@cornerstonejs/core 0.33.1 → 0.33.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.
- package/dist/cjs/utilities/getTargetVolumeAndSpacingInNormalDir.d.ts +1 -0
- package/dist/cjs/utilities/getTargetVolumeAndSpacingInNormalDir.js +22 -7
- package/dist/cjs/utilities/getTargetVolumeAndSpacingInNormalDir.js.map +1 -1
- package/dist/esm/utilities/getTargetVolumeAndSpacingInNormalDir.d.ts +1 -0
- package/dist/esm/utilities/getTargetVolumeAndSpacingInNormalDir.js +22 -7
- package/dist/esm/utilities/getTargetVolumeAndSpacingInNormalDir.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -2,4 +2,5 @@ import { ICamera, IImageVolume, IVolumeViewport } from '../types';
|
|
|
2
2
|
export default function getTargetVolumeAndSpacingInNormalDir(viewport: IVolumeViewport, camera: ICamera, targetVolumeId?: string): {
|
|
3
3
|
imageVolume: IImageVolume;
|
|
4
4
|
spacingInNormalDirection: number;
|
|
5
|
+
actorUID: string;
|
|
5
6
|
};
|
|
@@ -4,38 +4,53 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const cache_1 = __importDefault(require("../cache/cache"));
|
|
7
|
+
const constants_1 = require("../constants");
|
|
7
8
|
const getSpacingInNormalDirection_1 = __importDefault(require("./getSpacingInNormalDirection"));
|
|
9
|
+
const EPSILON_PART = 1 + constants_1.EPSILON;
|
|
8
10
|
function getTargetVolumeAndSpacingInNormalDir(viewport, camera, targetVolumeId) {
|
|
9
11
|
const { viewPlaneNormal } = camera;
|
|
10
12
|
const volumeActors = viewport.getActors();
|
|
11
13
|
if (!volumeActors || !volumeActors.length) {
|
|
12
|
-
return {
|
|
14
|
+
return {
|
|
15
|
+
spacingInNormalDirection: null,
|
|
16
|
+
imageVolume: null,
|
|
17
|
+
actorUID: null,
|
|
18
|
+
};
|
|
13
19
|
}
|
|
14
20
|
const imageVolumes = volumeActors
|
|
15
21
|
.map((va) => {
|
|
16
22
|
var _a;
|
|
17
|
-
const
|
|
18
|
-
return cache_1.default.getVolume(
|
|
23
|
+
const actorUID = (_a = va.referenceId) !== null && _a !== void 0 ? _a : va.uid;
|
|
24
|
+
return cache_1.default.getVolume(actorUID);
|
|
19
25
|
})
|
|
20
26
|
.filter((iv) => !!iv);
|
|
21
27
|
if (targetVolumeId) {
|
|
22
|
-
const
|
|
28
|
+
const imageVolumeIndex = imageVolumes.findIndex((iv) => iv.volumeId === targetVolumeId);
|
|
29
|
+
const imageVolume = imageVolumes[imageVolumeIndex];
|
|
30
|
+
const { uid: actorUID } = volumeActors[imageVolumeIndex];
|
|
23
31
|
const spacingInNormalDirection = (0, getSpacingInNormalDirection_1.default)(imageVolume, viewPlaneNormal);
|
|
24
|
-
return { imageVolume, spacingInNormalDirection };
|
|
32
|
+
return { imageVolume, spacingInNormalDirection, actorUID };
|
|
25
33
|
}
|
|
26
34
|
if (!imageVolumes.length) {
|
|
27
|
-
return {
|
|
35
|
+
return {
|
|
36
|
+
spacingInNormalDirection: null,
|
|
37
|
+
imageVolume: null,
|
|
38
|
+
actorUID: null,
|
|
39
|
+
};
|
|
28
40
|
}
|
|
29
41
|
const smallest = {
|
|
30
42
|
spacingInNormalDirection: Infinity,
|
|
31
43
|
imageVolume: null,
|
|
44
|
+
actorUID: null,
|
|
32
45
|
};
|
|
33
46
|
for (let i = 0; i < imageVolumes.length; i++) {
|
|
34
47
|
const imageVolume = imageVolumes[i];
|
|
35
48
|
const spacingInNormalDirection = (0, getSpacingInNormalDirection_1.default)(imageVolume, viewPlaneNormal);
|
|
36
|
-
if (spacingInNormalDirection
|
|
49
|
+
if (spacingInNormalDirection * EPSILON_PART <
|
|
50
|
+
smallest.spacingInNormalDirection) {
|
|
37
51
|
smallest.spacingInNormalDirection = spacingInNormalDirection;
|
|
38
52
|
smallest.imageVolume = imageVolume;
|
|
53
|
+
smallest.actorUID = volumeActors[i].uid;
|
|
39
54
|
}
|
|
40
55
|
}
|
|
41
56
|
return smallest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTargetVolumeAndSpacingInNormalDir.js","sourceRoot":"","sources":["../../../src/utilities/getTargetVolumeAndSpacingInNormalDir.ts"],"names":[],"mappings":";;;;;AAAA,2DAAmC;
|
|
1
|
+
{"version":3,"file":"getTargetVolumeAndSpacingInNormalDir.js","sourceRoot":"","sources":["../../../src/utilities/getTargetVolumeAndSpacingInNormalDir.ts"],"names":[],"mappings":";;;;;AAAA,2DAAmC;AACnC,4CAAuC;AAGvC,gGAAwE;AAGxE,MAAM,YAAY,GAAG,CAAC,GAAG,mBAAO,CAAC;AAiBjC,SAAwB,oCAAoC,CAC1D,QAAyB,EACzB,MAAe,EACf,cAAuB;IAMvB,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IACnC,MAAM,YAAY,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC;IAE1C,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;QACzC,OAAO;YACL,wBAAwB,EAAE,IAAI;YAC9B,WAAW,EAAE,IAAI;YACjB,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IAED,MAAM,YAAY,GAAG,YAAY;SAC9B,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;;QAGV,MAAM,QAAQ,GAAG,MAAA,EAAE,CAAC,WAAW,mCAAI,EAAE,CAAC,GAAG,CAAC;QAC1C,OAAO,eAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAGxB,IAAI,cAAc,EAAE;QAClB,MAAM,gBAAgB,GAAG,YAAY,CAAC,SAAS,CAC7C,CAAC,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ormalDir(viewport: IVolumeViewport, camera: ICamera, targetVolumeId?: string): {
|
|
3
3
|
imageVolume: IImageVolume;
|
|
4
4
|
spacingInNormalDirection: number;
|
|
5
|
+
actorUID: string;
|
|
5
6
|
};
|
|
@@ -1,35 +1,50 @@
|
|
|
1
1
|
import cache from '../cache/cache';
|
|
2
|
+
import { EPSILON } from '../constants';
|
|
2
3
|
import getSpacingInNormalDirection from './getSpacingInNormalDirection';
|
|
4
|
+
const EPSILON_PART = 1 + EPSILON;
|
|
3
5
|
export default function getTargetVolumeAndSpacingInNormalDir(viewport, camera, targetVolumeId) {
|
|
4
6
|
const { viewPlaneNormal } = camera;
|
|
5
7
|
const volumeActors = viewport.getActors();
|
|
6
8
|
if (!volumeActors || !volumeActors.length) {
|
|
7
|
-
return {
|
|
9
|
+
return {
|
|
10
|
+
spacingInNormalDirection: null,
|
|
11
|
+
imageVolume: null,
|
|
12
|
+
actorUID: null,
|
|
13
|
+
};
|
|
8
14
|
}
|
|
9
15
|
const imageVolumes = volumeActors
|
|
10
16
|
.map((va) => {
|
|
11
|
-
const
|
|
12
|
-
return cache.getVolume(
|
|
17
|
+
const actorUID = va.referenceId ?? va.uid;
|
|
18
|
+
return cache.getVolume(actorUID);
|
|
13
19
|
})
|
|
14
20
|
.filter((iv) => !!iv);
|
|
15
21
|
if (targetVolumeId) {
|
|
16
|
-
const
|
|
22
|
+
const imageVolumeIndex = imageVolumes.findIndex((iv) => iv.volumeId === targetVolumeId);
|
|
23
|
+
const imageVolume = imageVolumes[imageVolumeIndex];
|
|
24
|
+
const { uid: actorUID } = volumeActors[imageVolumeIndex];
|
|
17
25
|
const spacingInNormalDirection = getSpacingInNormalDirection(imageVolume, viewPlaneNormal);
|
|
18
|
-
return { imageVolume, spacingInNormalDirection };
|
|
26
|
+
return { imageVolume, spacingInNormalDirection, actorUID };
|
|
19
27
|
}
|
|
20
28
|
if (!imageVolumes.length) {
|
|
21
|
-
return {
|
|
29
|
+
return {
|
|
30
|
+
spacingInNormalDirection: null,
|
|
31
|
+
imageVolume: null,
|
|
32
|
+
actorUID: null,
|
|
33
|
+
};
|
|
22
34
|
}
|
|
23
35
|
const smallest = {
|
|
24
36
|
spacingInNormalDirection: Infinity,
|
|
25
37
|
imageVolume: null,
|
|
38
|
+
actorUID: null,
|
|
26
39
|
};
|
|
27
40
|
for (let i = 0; i < imageVolumes.length; i++) {
|
|
28
41
|
const imageVolume = imageVolumes[i];
|
|
29
42
|
const spacingInNormalDirection = getSpacingInNormalDirection(imageVolume, viewPlaneNormal);
|
|
30
|
-
if (spacingInNormalDirection
|
|
43
|
+
if (spacingInNormalDirection * EPSILON_PART <
|
|
44
|
+
smallest.spacingInNormalDirection) {
|
|
31
45
|
smallest.spacingInNormalDirection = spacingInNormalDirection;
|
|
32
46
|
smallest.imageVolume = imageVolume;
|
|
47
|
+
smallest.actorUID = volumeActors[i].uid;
|
|
33
48
|
}
|
|
34
49
|
}
|
|
35
50
|
return smallest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTargetVolumeAndSpacingInNormalDir.js","sourceRoot":"","sources":["../../../src/utilities/getTargetVolumeAndSpacingInNormalDir.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"getTargetVolumeAndSpacingInNormalDir.js","sourceRoot":"","sources":["../../../src/utilities/getTargetVolumeAndSpacingInNormalDir.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,gBAAgB,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,2BAA2B,MAAM,+BAA+B,CAAC;AAGxE,MAAM,YAAY,GAAG,CAAC,GAAG,OAAO,CAAC;AAiBjC,MAAM,CAAC,OAAO,UAAU,oCAAoC,CAC1D,QAAyB,EACzB,MAAe,EACf,cAAuB;IAMvB,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IACnC,MAAM,YAAY,GAAG,QAA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