@cornerstonejs/core 4.15.19 → 4.15.21

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.
@@ -15,6 +15,7 @@ import { RENDERING_DEFAULTS } from '../constants';
15
15
  import { InterpolationType } from '../enums';
16
16
  import { deepClone } from '../utilities/deepClone';
17
17
  import { updatePlaneRestriction } from '../utilities/updatePlaneRestriction';
18
+ import { getCubeSizeInView } from '../utilities/getPlaneCubeIntersectionDimensions';
18
19
  import { getConfiguration } from '../init';
19
20
  class Viewport {
20
21
  static { this.CameraViewPresentation = {
@@ -526,7 +527,9 @@ class Viewport {
526
527
  const idx = [middleIJK[0], middleIJK[1], middleIJK[2]];
527
528
  imageData.indexToWorld(idx, focalPoint);
528
529
  }
529
- let { widthWorld, heightWorld } = this._getWorldDistanceViewUpAndViewRight(bounds, viewUp, viewPlaneNormal);
530
+ let { widthWorld, heightWorld } = imageData
531
+ ? getCubeSizeInView(imageData, viewPlaneNormal, viewUp)
532
+ : this._getWorldDistanceViewUpAndViewRight(bounds, viewUp, viewPlaneNormal);
530
533
  if (imageData) {
531
534
  const spacing = imageData.getSpacing();
532
535
  widthWorld = Math.max(spacing[0], widthWorld - spacing[0]);
@@ -0,0 +1,7 @@
1
+ import type { Point3 } from '../types';
2
+ import type vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
3
+ export declare function getCubeSizeInView(imageData: vtkImageData, viewPlaneNormal: Point3, viewUp: Point3): {
4
+ widthWorld: number;
5
+ heightWorld: number;
6
+ depthWorld: number;
7
+ };
@@ -0,0 +1,28 @@
1
+ import { rotateToViewCoordinates } from './rotateToViewCoordinates';
2
+ function findMinCornerIndex(viewCorners, dimension) {
3
+ let minIndex = 0;
4
+ let minValue = viewCorners[0][dimension];
5
+ for (let i = 1; i < viewCorners.length; i++) {
6
+ if (viewCorners[i][dimension] < minValue) {
7
+ minValue = viewCorners[i][dimension];
8
+ minIndex = i;
9
+ }
10
+ }
11
+ return minIndex;
12
+ }
13
+ function calculateSize(viewCorners, dimension) {
14
+ const minIndex = findMinCornerIndex(viewCorners, dimension);
15
+ const maxIndex = minIndex ^ 7;
16
+ return viewCorners[maxIndex][dimension] - viewCorners[minIndex][dimension];
17
+ }
18
+ export function getCubeSizeInView(imageData, viewPlaneNormal, viewUp) {
19
+ const viewCorners = rotateToViewCoordinates(imageData, viewPlaneNormal, viewUp);
20
+ const maxWidth = calculateSize(viewCorners, 0);
21
+ const maxHeight = calculateSize(viewCorners, 1);
22
+ const maxDepth = calculateSize(viewCorners, 2);
23
+ return {
24
+ widthWorld: maxWidth,
25
+ heightWorld: maxHeight,
26
+ depthWorld: maxDepth,
27
+ };
28
+ }
@@ -93,6 +93,8 @@ import calculateSpacingBetweenImageIds from './calculateSpacingBetweenImageIds';
93
93
  export * as logger from './logger';
94
94
  import { calculateNeighborhoodStats } from './calculateNeighborhoodStats';
95
95
  export * from './getPixelSpacingInformation';
96
+ export * from './getPlaneCubeIntersectionDimensions';
97
+ export * from './rotateToViewCoordinates';
96
98
  import { asArray } from './asArray';
97
99
  export { updatePlaneRestriction } from './updatePlaneRestriction';
98
100
  declare const getViewportModality: (viewport: IViewport, volumeId?: string) => string;
@@ -94,6 +94,8 @@ import calculateSpacingBetweenImageIds from './calculateSpacingBetweenImageIds';
94
94
  export * as logger from './logger';
95
95
  import { calculateNeighborhoodStats } from './calculateNeighborhoodStats';
96
96
  export * from './getPixelSpacingInformation';
97
+ export * from './getPlaneCubeIntersectionDimensions';
98
+ export * from './rotateToViewCoordinates';
97
99
  import { asArray } from './asArray';
98
100
  export { updatePlaneRestriction } from './updatePlaneRestriction';
99
101
  const getViewportModality = (viewport, volumeId) => _getViewportModality(viewport, volumeId, cache.getVolume);
@@ -0,0 +1,3 @@
1
+ import type { Point3 } from '../types';
2
+ import type vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData';
3
+ export declare function rotateToViewCoordinates(imageData: vtkImageData, viewPlaneNormal: Point3, viewUp: Point3): Point3[];
@@ -0,0 +1,33 @@
1
+ import { vec3 } from 'gl-matrix';
2
+ export function rotateToViewCoordinates(imageData, viewPlaneNormal, viewUp) {
3
+ const viewRight = vec3.cross(vec3.create(), viewPlaneNormal, viewUp);
4
+ vec3.normalize(viewRight, viewRight);
5
+ const extent = imageData.getExtent();
6
+ const xMin = extent[0];
7
+ const xMax = extent[1] + 1;
8
+ const yMin = extent[2];
9
+ const yMax = extent[3] + 1;
10
+ const zMin = extent[4];
11
+ const zMax = extent[5] + 1;
12
+ const corners = [
13
+ [xMin, yMin, zMin],
14
+ [xMax, yMin, zMin],
15
+ [xMin, yMax, zMin],
16
+ [xMax, yMax, zMin],
17
+ [xMin, yMin, zMax],
18
+ [xMax, yMin, zMax],
19
+ [xMin, yMax, zMax],
20
+ [xMax, yMax, zMax],
21
+ ];
22
+ const viewCorners = corners.map((corner) => {
23
+ const worldPoint = [0, 0, 0];
24
+ imageData.indexToWorld(corner, worldPoint);
25
+ const viewPoint = [
26
+ vec3.dot(worldPoint, viewRight),
27
+ vec3.dot(worldPoint, viewUp),
28
+ vec3.dot(worldPoint, viewPlaneNormal),
29
+ ];
30
+ return viewPoint;
31
+ });
32
+ return viewCorners;
33
+ }
@@ -1 +1 @@
1
- export declare const version = "4.15.19";
1
+ export declare const version = "4.15.21";
@@ -1 +1 @@
1
- export const version = '4.15.19';
1
+ export const version = '4.15.21';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "4.15.19",
3
+ "version": "4.15.21",
4
4
  "description": "Cornerstone3D Core",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -97,5 +97,5 @@
97
97
  "type": "individual",
98
98
  "url": "https://ohif.org/donate"
99
99
  },
100
- "gitHead": "dd0f433bee1e2b63177b21a52cb1b2cc39f0a88f"
100
+ "gitHead": "86303ca350c2e722b60f9de979c21d2592d0139d"
101
101
  }