@cornerstonejs/core 3.1.0 → 3.1.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.
@@ -67,6 +67,7 @@ declare abstract class BaseVolumeViewport extends Viewport {
67
67
  setCamera(cameraInterface: ICamera, storeAsInitialCamera?: boolean): void;
68
68
  private _setVolumeActors;
69
69
  canvasToWorld: (canvasPos: Point2) => Point3;
70
+ getVTKDisplayCoords: (canvasPos: Point2) => Point3;
70
71
  worldToCanvas: (worldPos: Point3) => Point2;
71
72
  hasImageURI: (imageURI: string) => boolean;
72
73
  protected _getOrientationVectors(orientation: OrientationAxis | OrientationVectors): OrientationVectors;
@@ -151,22 +151,28 @@ class BaseVolumeViewport extends Viewport {
151
151
  const vtkCamera = this.getVtkActiveCamera();
152
152
  vtkCamera.setIsPerformingCoordinateTransformation?.(true);
153
153
  const renderer = this.getRenderer();
154
+ const displayCoords = this.getVTKDisplayCoords(canvasPos);
154
155
  const offscreenMultiRenderWindow = this.getRenderingEngine().offscreenMultiRenderWindow;
155
156
  const openGLRenderWindow = offscreenMultiRenderWindow.getOpenGLRenderWindow();
156
- const size = openGLRenderWindow.getSize();
157
+ const worldCoord = openGLRenderWindow.displayToWorld(displayCoords[0], displayCoords[1], displayCoords[2], renderer);
158
+ vtkCamera.setIsPerformingCoordinateTransformation?.(false);
159
+ return [worldCoord[0], worldCoord[1], worldCoord[2]];
160
+ };
161
+ this.getVTKDisplayCoords = (canvasPos) => {
157
162
  const devicePixelRatio = window.devicePixelRatio || 1;
158
163
  const canvasPosWithDPR = [
159
164
  canvasPos[0] * devicePixelRatio,
160
165
  canvasPos[1] * devicePixelRatio,
161
166
  ];
167
+ const offscreenMultiRenderWindow = this.getRenderingEngine().offscreenMultiRenderWindow;
168
+ const openGLRenderWindow = offscreenMultiRenderWindow.getOpenGLRenderWindow();
169
+ const size = openGLRenderWindow.getSize();
162
170
  const displayCoord = [
163
171
  canvasPosWithDPR[0] + this.sx,
164
172
  canvasPosWithDPR[1] + this.sy,
165
173
  ];
166
174
  displayCoord[1] = size[1] - displayCoord[1];
167
- const worldCoord = openGLRenderWindow.displayToWorld(displayCoord[0], displayCoord[1], 0, renderer);
168
- vtkCamera.setIsPerformingCoordinateTransformation?.(false);
169
- return [worldCoord[0], worldCoord[1], worldCoord[2]];
175
+ return [displayCoord[0], displayCoord[1], 0];
170
176
  };
171
177
  this.worldToCanvas = (worldPos) => {
172
178
  const vtkCamera = this.getVtkActiveCamera();
@@ -1163,6 +1163,9 @@ class StackViewport extends Viewport {
1163
1163
  async setStack(imageIds, currentImageIdIndex = 0) {
1164
1164
  this._throwIfDestroyed();
1165
1165
  this.imageIds = imageIds;
1166
+ if (currentImageIdIndex > imageIds.length) {
1167
+ throw new Error('Current image index is greater than the number of images in the stack');
1168
+ }
1166
1169
  this.imageKeyToIndexMap.clear();
1167
1170
  imageIds.forEach((imageId, index) => {
1168
1171
  this.imageKeyToIndexMap.set(imageId, index);
@@ -69,10 +69,12 @@ export default class VoxelManager<T> {
69
69
  getScalarDataLength(): number;
70
70
  get sizeInBytes(): number;
71
71
  get bytePerVoxel(): number;
72
+ clearBounds(): void;
72
73
  clear(): void;
73
74
  getConstructor(): new (length: number) => PixelDataTypedArray;
74
75
  getArrayOfModifiedSlices(): number[];
75
76
  resetModifiedSlices(): void;
77
+ setBounds(bounds: BoundsIJK): void;
76
78
  static addBounds(bounds: BoundsIJK, point: Point3): void;
77
79
  addPoint(point: Point3 | number): void;
78
80
  getPoints(): Point3[];
@@ -225,6 +225,10 @@ export default class VoxelManager {
225
225
  const boundsIJK = options?.boundsIJK || this.getBoundsIJK();
226
226
  const { isWithinObject } = options || {};
227
227
  const map = this.map;
228
+ if (!map) {
229
+ console.warn('No map found, you need to use a map voxel manager to use rleForEach');
230
+ return;
231
+ }
228
232
  map.defaultValue = undefined;
229
233
  for (let k = boundsIJK[2][0]; k <= boundsIJK[2][1]; k++) {
230
234
  for (let j = boundsIJK[1][0]; j <= boundsIJK[1][1]; j++) {
@@ -286,12 +290,15 @@ export default class VoxelManager {
286
290
  const value = this._get(0);
287
291
  return value.BYTES_PER_ELEMENT;
288
292
  }
289
- clear() {
290
- this.map?.clear();
293
+ clearBounds() {
291
294
  this.boundsIJK.map((bound) => {
292
295
  bound[0] = Infinity;
293
296
  bound[1] = -Infinity;
294
297
  });
298
+ }
299
+ clear() {
300
+ this.map?.clear();
301
+ this.clearBounds();
295
302
  this.modifiedSlices.clear();
296
303
  this.points?.clear();
297
304
  }
@@ -311,6 +318,9 @@ export default class VoxelManager {
311
318
  resetModifiedSlices() {
312
319
  this.modifiedSlices.clear();
313
320
  }
321
+ setBounds(bounds) {
322
+ this.boundsIJK = bounds;
323
+ }
314
324
  static addBounds(bounds, point) {
315
325
  if (!bounds) {
316
326
  bounds = [
@@ -1,6 +1,9 @@
1
1
  import * as metaData from '../metaData';
2
2
  import isEqual from './isEqual';
3
3
  function isValidVolume(imageIds) {
4
+ if (imageIds.length <= 1) {
5
+ return false;
6
+ }
4
7
  const imageId0 = imageIds[0];
5
8
  const { modality, seriesInstanceUID } = metaData.get('generalSeriesModule', imageId0);
6
9
  const { imageOrientationPatient, pixelSpacing, frameOfReferenceUID, columns, rows, } = metaData.get('imagePlaneModule', imageId0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/core",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "Cornerstone3D Core",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/esm/index.d.ts",
@@ -81,5 +81,5 @@
81
81
  "type": "individual",
82
82
  "url": "https://ohif.org/donate"
83
83
  },
84
- "gitHead": "227a990a55bc2dbfb95757f0860ff1a52dd3ab86"
84
+ "gitHead": "eb97520fe08be3b204a9b8a6d77463e5207f3422"
85
85
  }