@cornerstonejs/core 1.85.1 → 1.86.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "1.85.1",
3
+ "version": "1.86.0",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -47,5 +47,5 @@
47
47
  "type": "individual",
48
48
  "url": "https://ohif.org/donate"
49
49
  },
50
- "gitHead": "042a87e58cdb6c975ed540a94c071469f1aead77"
50
+ "gitHead": "089ac3e50d40067ff93e73a4c0e6bbf6594a6c98"
51
51
  }
@@ -34,7 +34,6 @@ import type {
34
34
  StackViewportProperties,
35
35
  VOIRange,
36
36
  ViewReference,
37
- ViewPresentation,
38
37
  VolumeActor,
39
38
  } from '../types';
40
39
  import {
@@ -46,6 +45,7 @@ import {
46
45
  actorIsA,
47
46
  colormap as colormapUtils,
48
47
  createSigmoidRGBTransferFunction,
48
+ getSpacingInNormalDirection,
49
49
  imageIdToURI,
50
50
  imageRetrieveMetadataProvider,
51
51
  invertRgbTransferFunction,
@@ -2893,6 +2893,10 @@ class StackViewport extends Viewport implements IStackViewport, IImagesLoader {
2893
2893
 
2894
2894
  /**
2895
2895
  * Checks to see if this target is or could be shown in this viewport
2896
+ *
2897
+ * @param viewRef - view reference
2898
+ * @param options - reference compatible options
2899
+ * @returns boolean if reference is viewable
2896
2900
  */
2897
2901
  public isReferenceViewable(
2898
2902
  viewRef: ViewReference,
@@ -2922,7 +2926,39 @@ class StackViewport extends Viewport implements IStackViewport, IImagesLoader {
2922
2926
  const colonIndex = imageId.indexOf(':');
2923
2927
  imageURI = imageId.substring(colonIndex + 1);
2924
2928
  }
2925
- return referencedImageId?.endsWith(imageURI);
2929
+
2930
+ const endsWith = referencedImageId?.endsWith(imageURI);
2931
+ if (endsWith) {
2932
+ return endsWith;
2933
+ }
2934
+
2935
+ // if camera focal point is provided, we can use that as a point
2936
+ // Todo: handle the case where the nearby project is not desired
2937
+ const { cameraFocalPoint } = viewRef;
2938
+
2939
+ if (options.asNearbyProjection && cameraFocalPoint) {
2940
+ const { spacing, direction, origin } = this.getImageData();
2941
+
2942
+ const viewPlaneNormal = direction.slice(6, 9) as Point3;
2943
+
2944
+ const sliceThickness = getSpacingInNormalDirection(
2945
+ { direction, spacing },
2946
+ viewPlaneNormal
2947
+ );
2948
+
2949
+ // Project the cameraFocalPoint onto the image plane
2950
+ const diff = vec3.subtract(vec3.create(), cameraFocalPoint, origin);
2951
+ const distanceToPlane = vec3.dot(diff, viewPlaneNormal);
2952
+
2953
+ // Define a threshold (e.g., half the slice thickness)
2954
+ const threshold = sliceThickness / 2;
2955
+
2956
+ if (Math.abs(distanceToPlane) <= threshold) {
2957
+ return true;
2958
+ }
2959
+ }
2960
+
2961
+ return false;
2926
2962
  }
2927
2963
 
2928
2964
  /**
@@ -69,6 +69,10 @@ export type ReferenceCompatibleOptions = {
69
69
  * not need to be provided.
70
70
  */
71
71
  imageURI?: string;
72
+ /**
73
+ * As nearby projection
74
+ */
75
+ asNearbyProjection?: boolean;
72
76
  };
73
77
 
74
78
  /**