@cornerstonejs/core 1.42.1 → 1.43.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.
Files changed (69) hide show
  1. package/dist/cjs/RenderingEngine/BaseVolumeViewport.js +3 -0
  2. package/dist/cjs/RenderingEngine/BaseVolumeViewport.js.map +1 -1
  3. package/dist/cjs/RenderingEngine/Viewport.d.ts +1 -0
  4. package/dist/cjs/RenderingEngine/Viewport.js +3 -0
  5. package/dist/cjs/RenderingEngine/Viewport.js.map +1 -1
  6. package/dist/cjs/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js +1 -1
  7. package/dist/cjs/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js.map +1 -1
  8. package/dist/cjs/loaders/imageLoader.d.ts +6 -1
  9. package/dist/cjs/loaders/imageLoader.js +20 -10
  10. package/dist/cjs/loaders/imageLoader.js.map +1 -1
  11. package/dist/cjs/loaders/volumeLoader.d.ts +1 -0
  12. package/dist/cjs/loaders/volumeLoader.js +9 -1
  13. package/dist/cjs/loaders/volumeLoader.js.map +1 -1
  14. package/dist/cjs/types/BoundsLPS.d.ts +3 -0
  15. package/dist/cjs/types/BoundsLPS.js +3 -0
  16. package/dist/cjs/types/BoundsLPS.js.map +1 -0
  17. package/dist/cjs/types/IViewport.d.ts +1 -0
  18. package/dist/cjs/types/index.d.ts +2 -1
  19. package/dist/cjs/utilities/VoxelManager.js +13 -4
  20. package/dist/cjs/utilities/VoxelManager.js.map +1 -1
  21. package/dist/cjs/utilities/planar.d.ts +1 -1
  22. package/dist/cjs/utilities/planar.js +5 -1
  23. package/dist/cjs/utilities/planar.js.map +1 -1
  24. package/dist/esm/RenderingEngine/BaseVolumeViewport.js +3 -0
  25. package/dist/esm/RenderingEngine/BaseVolumeViewport.js.map +1 -1
  26. package/dist/esm/RenderingEngine/Viewport.js +3 -0
  27. package/dist/esm/RenderingEngine/Viewport.js.map +1 -1
  28. package/dist/esm/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js +1 -1
  29. package/dist/esm/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js.map +1 -1
  30. package/dist/esm/loaders/imageLoader.js +18 -7
  31. package/dist/esm/loaders/imageLoader.js.map +1 -1
  32. package/dist/esm/loaders/volumeLoader.js +8 -0
  33. package/dist/esm/loaders/volumeLoader.js.map +1 -1
  34. package/dist/esm/types/BoundsLPS.js +2 -0
  35. package/dist/esm/types/BoundsLPS.js.map +1 -0
  36. package/dist/esm/utilities/VoxelManager.js +13 -4
  37. package/dist/esm/utilities/VoxelManager.js.map +1 -1
  38. package/dist/esm/utilities/planar.js +5 -1
  39. package/dist/esm/utilities/planar.js.map +1 -1
  40. package/dist/types/RenderingEngine/BaseVolumeViewport.d.ts.map +1 -1
  41. package/dist/types/RenderingEngine/Viewport.d.ts +1 -0
  42. package/dist/types/RenderingEngine/Viewport.d.ts.map +1 -1
  43. package/dist/types/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.d.ts.map +1 -1
  44. package/dist/types/loaders/imageLoader.d.ts +6 -1
  45. package/dist/types/loaders/imageLoader.d.ts.map +1 -1
  46. package/dist/types/loaders/volumeLoader.d.ts +1 -0
  47. package/dist/types/loaders/volumeLoader.d.ts.map +1 -1
  48. package/dist/types/types/BoundsLPS.d.ts +4 -0
  49. package/dist/types/types/BoundsLPS.d.ts.map +1 -0
  50. package/dist/types/types/IViewport.d.ts +1 -0
  51. package/dist/types/types/IViewport.d.ts.map +1 -1
  52. package/dist/types/types/index.d.ts +2 -1
  53. package/dist/types/types/index.d.ts.map +1 -1
  54. package/dist/types/utilities/VoxelManager.d.ts.map +1 -1
  55. package/dist/types/utilities/planar.d.ts +1 -1
  56. package/dist/types/utilities/planar.d.ts.map +1 -1
  57. package/dist/umd/index.js +1 -1
  58. package/dist/umd/index.js.map +1 -1
  59. package/package.json +3 -3
  60. package/src/RenderingEngine/BaseVolumeViewport.ts +4 -0
  61. package/src/RenderingEngine/Viewport.ts +9 -1
  62. package/src/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js +3 -26
  63. package/src/loaders/imageLoader.ts +52 -8
  64. package/src/loaders/volumeLoader.ts +21 -0
  65. package/src/types/BoundsLPS.ts +5 -0
  66. package/src/types/IViewport.ts +2 -1
  67. package/src/types/index.ts +2 -0
  68. package/src/utilities/VoxelManager.ts +15 -4
  69. package/src/utilities/planar.ts +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "1.42.1",
3
+ "version": "1.43.0",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -30,7 +30,7 @@
30
30
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
31
31
  },
32
32
  "dependencies": {
33
- "@kitware/vtk.js": "27.3.1",
33
+ "@kitware/vtk.js": "29.3.0",
34
34
  "comlink": "^4.4.1",
35
35
  "detect-gpu": "^5.0.22",
36
36
  "gl-matrix": "^3.4.3",
@@ -47,5 +47,5 @@
47
47
  "type": "individual",
48
48
  "url": "https://ohif.org/donate"
49
49
  },
50
- "gitHead": "14a1bff3ba983b6664529e8e829a655cc4ffda89"
50
+ "gitHead": "1681f72fb2df75001f844a2e1728f2e9b79b6985"
51
51
  }
@@ -1000,6 +1000,10 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
1000
1000
  ? vec3.negate(vec3.create(), this.initialViewUp)
1001
1001
  : this.initialViewUp;
1002
1002
 
1003
+ if (!initialViewUp) {
1004
+ return 0;
1005
+ }
1006
+
1003
1007
  // The angle between the initial and current view up vectors.
1004
1008
  // TODO: check with VTK about rounding errors here.
1005
1009
  const initialToCurrentViewUpAngle =
@@ -63,7 +63,7 @@ class Viewport implements IViewport {
63
63
  protected flipHorizontal = false;
64
64
  protected flipVertical = false;
65
65
  public isDisabled: boolean;
66
- /** Record the renddering status, mostly for testing purposes, but can also
66
+ /** Record the rendering status, mostly for testing purposes, but can also
67
67
  * be useful for knowing things like whether the viewport is initialized
68
68
  */
69
69
  public viewportStatus: ViewportStatus = ViewportStatus.NO_DATA;
@@ -373,6 +373,14 @@ class Viewport implements IViewport {
373
373
  return Array.from(this._actors.values());
374
374
  }
375
375
 
376
+ /**
377
+ * Returns an array of unique identifiers for all the actors in the viewport.
378
+ * @returns An array of strings
379
+ */
380
+ public getActorUIDs(): Array<string> {
381
+ return Array.from(this._actors.keys());
382
+ }
383
+
376
384
  /**
377
385
  * Get an actor by its UID
378
386
  * @param actorUID - The unique ID of the actor.
@@ -1,4 +1,3 @@
1
- import { mat3, mat4, vec3 } from 'gl-matrix';
2
1
  import macro from '@kitware/vtk.js/macros';
3
2
  import vtkOpenGLVolumeMapper from '@kitware/vtk.js/Rendering/OpenGL/VolumeMapper';
4
3
  import { Filter } from '@kitware/vtk.js/Rendering/OpenGL/Texture/Constants';
@@ -6,9 +5,8 @@ import { VtkDataTypes } from '@kitware/vtk.js/Common/Core/DataArray/Constants';
6
5
  import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
7
6
  import { Representation } from '@kitware/vtk.js/Rendering/Core/Property/Constants';
8
7
 
9
- const { vtkWarningMacro } = macro;
10
8
  /**
11
- * vtkStreamingOpenGLVolumeMapper - A dervied class of the core vtkOpenGLVolumeMapper class.
9
+ * vtkStreamingOpenGLVolumeMapper - A derived class of the core vtkOpenGLVolumeMapper class.
12
10
  * This class replaces the buildBufferObjects function so that we progressively upload our textures
13
11
  * into GPU memory using the new methods on vtkStreamingOpenGLTexture.
14
12
  *
@@ -155,6 +153,8 @@ function vtkStreamingOpenGLVolumeMapper(publicAPI, model) {
155
153
  model.colorTextureString = toString;
156
154
  }
157
155
 
156
+ publicAPI.updateLabelOutlineThicknessTexture(actor);
157
+
158
158
  // rebuild the scalarTexture if the data has changed
159
159
  toString = `${image.getMTime()}`;
160
160
 
@@ -246,29 +246,6 @@ function vtkStreamingOpenGLVolumeMapper(publicAPI, model) {
246
246
  model.VBOBuildTime.modified();
247
247
  };
248
248
 
249
- // publicAPI.getRenderTargetSize = () => {
250
- // // https://github.com/Kitware/vtk-js/blob/master/Sources/Rendering/OpenGL/VolumeMapper/index.js#L952
251
- // if (model.lastXYF > 1.43) {
252
- // const sz = model.framebuffer.getSize()
253
- // return [model.fvp[0] * sz[0], model.fvp[1] * sz[1]]
254
- // }
255
-
256
- // // This seems wrong, it assumes the renderWindow only has one renderer
257
- // // but I don't know if this stuff is correct...
258
-
259
- // const { usize, vsize } = model.openGLRenderer.getTiledSizeAndOrigin()
260
-
261
- // return [usize, vsize]
262
- // }
263
-
264
- // publicAPI.getRenderTargetSize = () => {
265
- // if (model._useSmallViewport) {
266
- // return [model._smallViewportWidth, model._smallViewportHeight]
267
- // }
268
-
269
- // return model._openGLRenderWindow.getFramebufferSize()
270
- // }
271
-
272
249
  publicAPI.getRenderTargetSize = () => {
273
250
  if (model._useSmallViewport) {
274
251
  return [model._smallViewportWidth, model._smallViewportHeight];
@@ -289,11 +289,16 @@ export function createAndCacheDerivedImage(
289
289
  * Load and cache a list of imageIds
290
290
  *
291
291
  * @param referencedImageIds - list of imageIds
292
- * @param getDerivedImageId - optional function to generate derived imageId name however you want
292
+ * @param options
293
+ * @param options.getDerivedImageId - function to get the derived imageId
294
+ * @param options.targetBufferType - target buffer type
293
295
  */
294
296
  export function createAndCacheDerivedImages(
295
297
  referencedImageIds: Array<string>,
296
- getDerivedImageId?: (referencedImageId: string) => string
298
+ options: {
299
+ getDerivedImageId?: (referencedImageId: string) => string;
300
+ targetBufferType?: PixelDataTypedArrayString;
301
+ } = {}
297
302
  ): DerivedImages {
298
303
  if (referencedImageIds?.length === 0) {
299
304
  throw new Error(
@@ -302,14 +307,15 @@ export function createAndCacheDerivedImages(
302
307
  }
303
308
 
304
309
  const derivedImageIds = [];
305
- const allPromises = referencedImageIds.map((referencedImageId, index) => {
306
- const options: DerivedImageOptions = {
307
- imageId: getDerivedImageId
308
- ? getDerivedImageId(referencedImageId)
310
+ const allPromises = referencedImageIds.map((referencedImageId) => {
311
+ const newOptions: DerivedImageOptions = {
312
+ imageId: options.getDerivedImageId
313
+ ? options.getDerivedImageId(referencedImageId)
309
314
  : `derived:${uuidv4()}`,
315
+ ...options,
310
316
  };
311
- derivedImageIds.push(options.imageId);
312
- return createAndCacheDerivedImage(referencedImageId, options);
317
+ derivedImageIds.push(newOptions.imageId);
318
+ return createAndCacheDerivedImage(referencedImageId, newOptions);
313
319
  });
314
320
 
315
321
  return { imageIds: derivedImageIds, promises: allPromises };
@@ -501,3 +507,41 @@ export function unregisterAllImageLoaders(): void {
501
507
  );
502
508
  unknownImageLoader = undefined;
503
509
  }
510
+
511
+ /**
512
+ * Creates and caches derived segmentation images based on the referenced imageIds, this
513
+ * is a helper function, we don't have segmentation concept in the cornerstone core; however,
514
+ * this helper would make it clear that the segmentation images SHOULD be Uint8Array type
515
+ * always until we have a better solution.
516
+ *
517
+ * @param referencedImageIds - An array of referenced image IDs.
518
+ * @param options - The options for creating the derived images (default: { targetBufferType: 'Uint8Array' }).
519
+ * @returns The derived images.
520
+ */
521
+ export function createAndCacheDerivedSegmentationImages(
522
+ referencedImageIds: Array<string>,
523
+ options: DerivedImageOptions = {
524
+ targetBufferType: 'Uint8Array',
525
+ }
526
+ ): DerivedImages {
527
+ return createAndCacheDerivedImages(referencedImageIds, options);
528
+ }
529
+
530
+ /**
531
+ * Creates and caches a derived segmentation image based on the referenced image ID.
532
+ * this is a helper function, we don't have segmentation concept in the cornerstone core; however,
533
+ * this helper would make it clear that the segmentation images SHOULD be Uint8Array type
534
+ * always until we have a better solution.
535
+ *
536
+ * @param referencedImageId The ID of the referenced image.
537
+ * @param options The options for creating the derived image (default: { targetBufferType: 'Uint8Array' }).
538
+ * @returns A promise that resolves to the created derived segmentation image.
539
+ */
540
+ export function createAndCacheDerivedSegmentationImage(
541
+ referencedImageId: string,
542
+ options: DerivedImageOptions = {
543
+ targetBufferType: 'Uint8Array',
544
+ }
545
+ ): Promise<IImage> {
546
+ return createAndCacheDerivedImage(referencedImageId, options);
547
+ }
@@ -561,3 +561,24 @@ export function registerUnknownVolumeLoader(
561
561
  export function getUnknownVolumeLoaderSchema(): string {
562
562
  return unknownVolumeLoader.name;
563
563
  }
564
+
565
+ /**
566
+ * Creates and caches a derived segmentation volume based on a referenced volume.
567
+ * This is basically a utility method since for the segmentations we have to specify
568
+ * Uint8Array as the targetBuffer type for now until we support other types.
569
+ *
570
+ * @param referencedVolumeId - The ID of the referenced volume.
571
+ * @param options - The options for creating the derived volume.
572
+ * @returns A promise that resolves to the created derived segmentation volume.
573
+ */
574
+ export async function createAndCacheDerivedSegmentationVolume(
575
+ referencedVolumeId: string,
576
+ options: DerivedVolumeOptions
577
+ ): Promise<IImageVolume> {
578
+ return createAndCacheDerivedVolume(referencedVolumeId, {
579
+ ...options,
580
+ targetBuffer: {
581
+ type: 'Uint8Array',
582
+ },
583
+ });
584
+ }
@@ -0,0 +1,5 @@
1
+ import type Point2 from './Point3';
2
+
3
+ type BoundsLPS = [Point2, Point2, Point2];
4
+
5
+ export default BoundsLPS;
@@ -6,7 +6,6 @@ import { ActorEntry } from './IActor';
6
6
  import ViewportType from '../enums/ViewportType';
7
7
  import ViewportStatus from '../enums/ViewportStatus';
8
8
  import DisplayArea from './displayArea';
9
- import { IRetrieveConfiguration } from './IRetrieveConfiguration';
10
9
 
11
10
  /**
12
11
  * Viewport interface for cornerstone viewports
@@ -66,6 +65,8 @@ interface IViewport {
66
65
  addActors(actors: Array<ActorEntry>): void;
67
66
  /** add one actor */
68
67
  addActor(actorEntry: ActorEntry): void;
68
+ /** get actor UIDs */
69
+ getActorUIDs(): Array<string>;
69
70
  /** remove all actors from the viewport */
70
71
  removeAllActors(): void;
71
72
  /** remove array of uids */
@@ -108,6 +108,7 @@ import type {
108
108
  import type BoundsIJK from './BoundsIJK';
109
109
  import type { ImageVolumeProps } from './ImageVolumeProps';
110
110
  import type { VolumeProps } from './VolumeProps';
111
+ import type BoundsLPS from './BoundsLPS';
111
112
 
112
113
  export type {
113
114
  // config
@@ -216,6 +217,7 @@ export type {
216
217
  InternalVideoCamera,
217
218
  VideoViewportInput,
218
219
  BoundsIJK,
220
+ BoundsLPS,
219
221
  Color,
220
222
  ColorLUT,
221
223
  VolumeProps,
@@ -216,10 +216,21 @@ export default class VoxelManager<T> {
216
216
  * Extends the bounds of this object to include the specified point
217
217
  */
218
218
  public static addBounds(bounds: BoundsIJK, point: Point3) {
219
- bounds.forEach((bound, index) => {
220
- bound[0] = Math.min(point[index], bound[0]);
221
- bound[1] = Math.max(point[index], bound[1]);
222
- });
219
+ if (!bounds) {
220
+ bounds = [
221
+ [Infinity, -Infinity],
222
+ [Infinity, -Infinity],
223
+ [Infinity, -Infinity],
224
+ ];
225
+ }
226
+
227
+ // Directly update the bounds for each axis
228
+ bounds[0][0] = Math.min(point[0], bounds[0][0]);
229
+ bounds[0][1] = Math.max(point[0], bounds[0][1]);
230
+ bounds[1][0] = Math.min(point[1], bounds[1][0]);
231
+ bounds[1][1] = Math.max(point[1], bounds[1][1]);
232
+ bounds[2][0] = Math.min(point[2], bounds[2][0]);
233
+ bounds[2][1] = Math.max(point[2], bounds[2][1]);
223
234
  }
224
235
 
225
236
  /**
@@ -28,11 +28,22 @@ function linePlaneIntersection(p0: Point3, p1: Point3, plane: Plane): Point3 {
28
28
  * It returns the plane equation defined by a point and a normal vector.
29
29
  * @param normal - normal vector
30
30
  * @param point - a point on the plane
31
+ * @param normalized - if true, the values of the plane equation will be normalized
31
32
  * @returns - [A, B,C, D] of plane equation A*X + B*Y + C*Z = D
32
33
  */
33
- function planeEquation(normal: Point3, point: Point3 | vec3): Plane {
34
+ function planeEquation(
35
+ normal: Point3,
36
+ point: Point3 | vec3,
37
+ normalized = false
38
+ ): Plane {
34
39
  const [A, B, C] = normal;
35
40
  const D = A * point[0] + B * point[1] + C * point[2];
41
+
42
+ if (normalized) {
43
+ const length = Math.sqrt(A * A + B * B + C * C);
44
+ return [A / length, B / length, C / length, D / length];
45
+ }
46
+
36
47
  return [A, B, C, D];
37
48
  }
38
49