@cornerstonejs/core 2.1.5 → 2.1.7

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.
@@ -317,6 +317,7 @@ class BaseVolumeViewport extends Viewport {
317
317
  colormap,
318
318
  volumeId,
319
319
  };
320
+ triggerEvent(this.element, Events.VOI_MODIFIED, eventDetail);
320
321
  triggerEvent(this.element, Events.COLORMAP_MODIFIED, eventDetail);
321
322
  }
322
323
  }
@@ -420,13 +421,9 @@ class BaseVolumeViewport extends Viewport {
420
421
  }
421
422
  const { volumeActor } = applicableVolumeActorInfo;
422
423
  const volumeIdToUse = applicableVolumeActorInfo.volumeId;
423
- let voiRangeToUse = voiRange;
424
+ const voiRangeToUse = voiRange;
424
425
  if (typeof voiRangeToUse === 'undefined') {
425
426
  throw new Error('voiRangeToUse is undefined, need to implement this in the new volume model');
426
- const imageData = volumeActor.getMapper().getInputData();
427
- const range = imageData.getPointData().getScalars().getRange();
428
- const maxVoiRange = { lower: range[0], upper: range[1] };
429
- voiRangeToUse = maxVoiRange;
430
427
  }
431
428
  const { VOILUTFunction } = this.getProperties(volumeIdToUse);
432
429
  if (VOILUTFunction === VOILUTFunctionType.SAMPLED_SIGMOID) {
@@ -3,7 +3,7 @@ import vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';
3
3
  import type { mat4 } from 'gl-matrix';
4
4
  import ViewportStatus from '../enums/ViewportStatus';
5
5
  import ViewportType from '../enums/ViewportType';
6
- import type { ICamera, ActorEntry, IRenderingEngine, ViewportInputOptions, Point2, Point3, FlipDirection, DisplayArea, ViewPresentation, ViewReference, ViewportProperties } from '../types';
6
+ import type { ICamera, ActorEntry, IRenderingEngine, ViewportInputOptions, Point2, Point3, FlipDirection, DisplayArea, ViewPresentation, ViewReference, ViewportProperties, ImageActor } from '../types';
7
7
  import type { ViewportInput, ViewReferenceSpecifier, ReferenceCompatibleOptions, ViewPresentationSelector, DataSetOptions } from '../types/IViewport';
8
8
  import type { vtkSlabCamera } from './vtkClasses/vtkSlabCamera';
9
9
  import type IImageCalibration from '../types/IImageCalibration';
@@ -72,6 +72,7 @@ declare class Viewport {
72
72
  getActors(): ActorEntry[];
73
73
  getActorUIDs(): string[];
74
74
  getActor(actorUID: string): ActorEntry;
75
+ getImageActor(volumeId?: string): ImageActor | null;
75
76
  getActorUIDByIndex(index: number): string;
76
77
  getActorByIndex(index: number): ActorEntry;
77
78
  setActors(actors: ActorEntry[]): void;
@@ -189,6 +189,18 @@ class Viewport {
189
189
  getActor(actorUID) {
190
190
  return this._actors.get(actorUID);
191
191
  }
192
+ getImageActor(volumeId) {
193
+ const actorEntries = this.getActors();
194
+ let actorEntry = actorEntries[0];
195
+ if (volumeId) {
196
+ actorEntry = actorEntries.find((a) => a.referencedId === volumeId);
197
+ }
198
+ if (!actorEntry || !isImageActor(actorEntry)) {
199
+ return null;
200
+ }
201
+ const actor = actorEntry.actor;
202
+ return actor;
203
+ }
192
204
  getActorUIDByIndex(index) {
193
205
  const actor = this.getActors()[index];
194
206
  if (actor) {
@@ -591,11 +603,18 @@ class Viewport {
591
603
  }
592
604
  getCameraNoRotation() {
593
605
  const vtkCamera = this.getVtkActiveCamera();
606
+ const sanitizeVector = (vector, defaultValue) => {
607
+ return vector.some((v) => isNaN(v)) ? defaultValue : vector;
608
+ };
609
+ const viewUp = sanitizeVector([...vtkCamera.getViewUp()], [0, 1, 0]);
610
+ const viewPlaneNormal = sanitizeVector([...vtkCamera.getViewPlaneNormal()], [0, 0, -1]);
611
+ const position = sanitizeVector([...vtkCamera.getPosition()], [0, 0, 1]);
612
+ const focalPoint = sanitizeVector([...vtkCamera.getFocalPoint()], [0, 0, 0]);
594
613
  return {
595
- viewUp: [...vtkCamera.getViewUp()],
596
- viewPlaneNormal: [...vtkCamera.getViewPlaneNormal()],
597
- position: [...vtkCamera.getPosition()],
598
- focalPoint: [...vtkCamera.getFocalPoint()],
614
+ viewUp,
615
+ viewPlaneNormal,
616
+ position,
617
+ focalPoint,
599
618
  parallelProjection: vtkCamera.getParallelProjection(),
600
619
  parallelScale: vtkCamera.getParallelScale(),
601
620
  viewAngle: vtkCamera.getViewAngle(),
@@ -166,7 +166,7 @@ class VolumeViewport extends BaseVolumeViewport {
166
166
  setCameraClippingRange() {
167
167
  const activeCamera = this.getVtkActiveCamera();
168
168
  if (activeCamera.getParallelProjection()) {
169
- activeCamera.setClippingRange(activeCamera.getDistance(), activeCamera.getDistance() + this.getSlabThickness());
169
+ activeCamera.setClippingRange(activeCamera.getDistance() - this.getSlabThickness(), activeCamera.getDistance() + this.getSlabThickness());
170
170
  }
171
171
  else {
172
172
  activeCamera.setClippingRange(RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS, RENDERING_DEFAULTS.MAXIMUM_RAY_DISTANCE);
@@ -72,6 +72,9 @@ function vtkStreamingOpenGLTexture(publicAPI, model) {
72
72
  function updateDynamicVolumeTexture() {
73
73
  const volume = cache.getVolume(model.volumeId);
74
74
  const imageIds = volume.getCurrentTimePointImageIds();
75
+ if (!imageIds.length) {
76
+ return false;
77
+ }
75
78
  let constructor;
76
79
  for (let i = 0; i < imageIds.length; i++) {
77
80
  const imageId = imageIds[i];
@@ -24,7 +24,7 @@ export default class BaseStreamingImageVolume extends ImageVolume implements IIm
24
24
  protected updateTextureAndTriggerEvents(imageIdIndex: any, imageId: any, imageQualityStatus?: ImageQualityStatus): void;
25
25
  successCallback(imageId: string, image: any): void;
26
26
  errorCallback(imageId: any, permanent: any, error: any): void;
27
- load: (callback: (...args: unknown[]) => void) => void;
27
+ load(callback: (...args: unknown[]) => void): void;
28
28
  getLoaderImageOptions(imageId: string): {
29
29
  targetBuffer: {
30
30
  type: import("../../types").PixelDataTypedArrayString;
@@ -32,38 +32,6 @@ export default class BaseStreamingImageVolume extends ImageVolume {
32
32
  };
33
33
  imageLoadPoolManager.filterRequests(filterFunction);
34
34
  };
35
- this.load = (callback) => {
36
- const { imageIds, loadStatus, numFrames } = this;
37
- const { transferSyntaxUID } = metaData.get('transferSyntax', imageIds[0]) || {};
38
- const imageRetrieveConfiguration = metaData.get(imageRetrieveMetadataProvider.IMAGE_RETRIEVE_CONFIGURATION, this.volumeId, transferSyntaxUID, 'volume');
39
- this.imagesLoader = this.isDynamicVolume()
40
- ? this
41
- : imageRetrieveConfiguration
42
- ? (imageRetrieveConfiguration.create ||
43
- ProgressiveRetrieveImages.createProgressive)(imageRetrieveConfiguration)
44
- : this;
45
- if (loadStatus.loading === true) {
46
- return;
47
- }
48
- const { loaded } = this.loadStatus;
49
- const totalNumFrames = imageIds.length;
50
- if (loaded) {
51
- if (callback) {
52
- callback({
53
- success: true,
54
- framesLoaded: totalNumFrames,
55
- framesProcessed: totalNumFrames,
56
- numFrames,
57
- totalNumFrames,
58
- });
59
- }
60
- return;
61
- }
62
- if (callback) {
63
- this.loadStatus.callbacks.push(callback);
64
- }
65
- this._prefetchImageIds();
66
- };
67
35
  this.loadStatus = streamingProperties.loadStatus;
68
36
  }
69
37
  invalidateVolume(immediate) {
@@ -190,6 +158,38 @@ export default class BaseStreamingImageVolume extends ImageVolume {
190
158
  };
191
159
  triggerEvent(eventTarget, Events.IMAGE_LOAD_ERROR, eventDetail);
192
160
  }
161
+ load(callback) {
162
+ const { imageIds, loadStatus, numFrames } = this;
163
+ const { transferSyntaxUID } = metaData.get('transferSyntax', imageIds[0]) || {};
164
+ const imageRetrieveConfiguration = metaData.get(imageRetrieveMetadataProvider.IMAGE_RETRIEVE_CONFIGURATION, this.volumeId, transferSyntaxUID, 'volume');
165
+ this.imagesLoader = this.isDynamicVolume()
166
+ ? this
167
+ : imageRetrieveConfiguration
168
+ ? (imageRetrieveConfiguration.create ||
169
+ ProgressiveRetrieveImages.createProgressive)(imageRetrieveConfiguration)
170
+ : this;
171
+ if (loadStatus.loading === true) {
172
+ return;
173
+ }
174
+ const { loaded } = this.loadStatus;
175
+ const totalNumFrames = imageIds.length;
176
+ if (loaded) {
177
+ if (callback) {
178
+ callback({
179
+ success: true,
180
+ framesLoaded: totalNumFrames,
181
+ framesProcessed: totalNumFrames,
182
+ numFrames,
183
+ totalNumFrames,
184
+ });
185
+ }
186
+ return;
187
+ }
188
+ if (callback) {
189
+ this.loadStatus.callbacks.push(callback);
190
+ }
191
+ this._prefetchImageIds();
192
+ }
193
193
  getLoaderImageOptions(imageId) {
194
194
  const { transferSyntaxUID: transferSyntaxUID } = metaData.get('transferSyntax', imageId) || {};
195
195
  const imagePlaneModule = metaData.get('imagePlaneModule', imageId) || {};
@@ -49,6 +49,7 @@ export declare class ImageVolume {
49
49
  getImageIdIndex(imageId: string): number;
50
50
  getImageIdByIndex(imageIdIndex: number): string;
51
51
  getImageURIIndex(imageURI: string): number;
52
+ load(callback: (...args: unknown[]) => void): void;
52
53
  destroy(): void;
53
54
  invalidate(): void;
54
55
  modified(): void;
@@ -97,6 +97,8 @@ export class ImageVolume {
97
97
  getImageURIIndex(imageURI) {
98
98
  return this._imageURIsIndexMap.get(imageURI);
99
99
  }
100
+ load(callback) {
101
+ }
100
102
  destroy() {
101
103
  this.imageData.delete();
102
104
  this.imageData = null;
@@ -3,6 +3,7 @@ import { RequestType } from '../enums';
3
3
  import imageLoadPoolManager from '../requestPool/imageLoadPoolManager';
4
4
  import { generateVolumePropsFromImageIds } from '../utilities';
5
5
  import { loadImage } from './imageLoader';
6
+ import { registerUnknownVolumeLoader } from './volumeLoader';
6
7
  function cornerstoneStreamingImageVolumeLoader(volumeId, options) {
7
8
  if (!options || !options.imageIds || !options.imageIds.length) {
8
9
  throw new Error('ImageIds must be provided to create a streaming image volume');
@@ -70,4 +71,5 @@ function cornerstoneStreamingImageVolumeLoader(volumeId, options) {
70
71
  },
71
72
  };
72
73
  }
74
+ registerUnknownVolumeLoader(cornerstoneStreamingImageVolumeLoader);
73
75
  export { cornerstoneStreamingImageVolumeLoader };
@@ -3,5 +3,4 @@ import { cornerstoneStreamingDynamicImageVolumeLoader } from './cornerstoneStrea
3
3
  import * as geometryLoader from './geometryLoader';
4
4
  import * as imageLoader from './imageLoader';
5
5
  import * as volumeLoader from './volumeLoader';
6
- volumeLoader.registerUnknownVolumeLoader(cornerstoneStreamingImageVolumeLoader);
7
6
  export { cornerstoneStreamingImageVolumeLoader, cornerstoneStreamingDynamicImageVolumeLoader, geometryLoader, imageLoader, volumeLoader, };
@@ -417,7 +417,8 @@ export default class VoxelManager {
417
417
  });
418
418
  };
419
419
  voxelManager.getRange = () => {
420
- let minValue, maxValue;
420
+ let minValue = Infinity;
421
+ let maxValue = -Infinity;
421
422
  for (const imageId of imageIds) {
422
423
  const image = cache.getImage(imageId);
423
424
  if (image.minPixelValue < minValue) {
@@ -529,36 +530,36 @@ export default class VoxelManager {
529
530
  numberOfComponents,
530
531
  });
531
532
  });
532
- const voxelManager = new VoxelManager(dimensions, (index) => voxelGroups[timePoint - 1]._get(index), (index, v) => voxelGroups[timePoint - 1]._set(index, v));
533
+ const voxelManager = new VoxelManager(dimensions, (index) => voxelGroups[timePoint]._get(index), (index, v) => voxelGroups[timePoint]._set(index, v));
533
534
  voxelManager.numberOfComponents = numberOfComponents;
534
535
  voxelManager.getScalarDataLength = () => {
535
- return voxelGroups[timePoint - 1].getScalarDataLength();
536
+ return voxelGroups[timePoint].getScalarDataLength();
536
537
  };
537
538
  voxelManager.getConstructor = () => {
538
- return voxelGroups[timePoint - 1].getConstructor();
539
+ return voxelGroups[timePoint].getConstructor();
539
540
  };
540
541
  voxelManager.getRange = () => {
541
- return voxelGroups[timePoint - 1].getRange();
542
+ return voxelGroups[timePoint].getRange();
542
543
  };
543
544
  voxelManager.getMiddleSliceData = () => {
544
- return voxelGroups[timePoint - 1].getMiddleSliceData();
545
+ return voxelGroups[timePoint].getMiddleSliceData();
545
546
  };
546
547
  voxelManager.setTimePoint = (newTimePoint) => {
547
548
  timePoint = newTimePoint;
548
- voxelManager._get = (index) => voxelGroups[timePoint - 1]._get(index);
549
- voxelManager._set = (index, v) => voxelGroups[timePoint - 1]._set(index, v);
549
+ voxelManager._get = (index) => voxelGroups[timePoint]._get(index);
550
+ voxelManager._set = (index, v) => voxelGroups[timePoint]._set(index, v);
550
551
  };
551
552
  voxelManager.getAtIndexAndTimePoint = (index, tp) => {
552
- return voxelGroups[tp - 1]._get(index);
553
+ return voxelGroups[tp]._get(index);
553
554
  };
554
555
  voxelManager.getTimePointScalarData = (tp) => {
555
- return voxelGroups[tp - 1].getCompleteScalarDataArray();
556
+ return voxelGroups[tp].getCompleteScalarDataArray();
556
557
  };
557
558
  voxelManager.getTimePointScalarData = (tp) => {
558
- return voxelGroups[tp - 1].getCompleteScalarDataArray();
559
+ return voxelGroups[tp].getCompleteScalarDataArray();
559
560
  };
560
561
  voxelManager.getCurrentTimePointScalarData = () => {
561
- return voxelGroups[timePoint - 1].getCompleteScalarDataArray();
562
+ return voxelGroups[timePoint].getCompleteScalarDataArray();
562
563
  };
563
564
  return voxelManager;
564
565
  }
@@ -80,7 +80,7 @@ class TargetEventListeners {
80
80
  this._target.addEventListener(type, callback, options);
81
81
  }
82
82
  _removeEventListener(type, callback, options) {
83
- const useCapture = options.capture ?? false;
83
+ const useCapture = options?.capture ?? false;
84
84
  const listenerPhase = useCapture
85
85
  ? EventListenerPhases.Capture
86
86
  : EventListenerPhases.Bubble;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "",
5
5
  "main": "./dist/umd/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -84,5 +84,5 @@
84
84
  "type": "individual",
85
85
  "url": "https://ohif.org/donate"
86
86
  },
87
- "gitHead": "0d41c41af381224b181100e98bd0a0d55e9d149b"
87
+ "gitHead": "079eb63faace4c72556559fc1ce272c2a9a910ca"
88
88
  }