@cornerstonejs/adapters 1.54.1 → 1.55.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.
@@ -38850,7 +38850,7 @@ class ProgressiveIterator {
38850
38850
  }
38851
38851
  }
38852
38852
 
38853
- function decimate(list, interleave, offset = 0) {
38853
+ function decimate$1(list, interleave, offset = 0) {
38854
38854
  const interleaveIndices = [];
38855
38855
  for (let i = offset; i < list.length; i += interleave) {
38856
38856
  interleaveIndices.push(i);
@@ -40746,6 +40746,7 @@ class Viewport {
40746
40746
  const renderer = this.getRenderer();
40747
40747
  renderer.addActor(actor);
40748
40748
  this._actors.set(actorUID, Object.assign({}, actorEntry));
40749
+ this.updateCameraClippingPlanesAndRange();
40749
40750
  }
40750
40751
  removeAllActors() {
40751
40752
  this.getRenderer().removeAllViewProps();
@@ -41129,6 +41130,11 @@ class Viewport {
41129
41130
  triggerEvent(this.element, EVENTS.CAMERA_MODIFIED, eventDetail);
41130
41131
  }
41131
41132
  }
41133
+ updateCameraClippingPlanesAndRange() {
41134
+ const currentCamera = this.getCamera();
41135
+ this.updateClippingPlanesForActors(currentCamera);
41136
+ this.getRenderer().resetCameraClippingRange();
41137
+ }
41132
41138
  async updateClippingPlanesForActors(updatedCamera) {
41133
41139
  const actorEntries = this.getActors();
41134
41140
  actorEntries.map(actorEntry => {
@@ -42457,7 +42463,7 @@ var utilities = /*#__PURE__*/Object.freeze({
42457
42463
  createSigmoidRGBTransferFunction: createSigmoidRGBTransferFunction,
42458
42464
  createUint16SharedArray: createUint16SharedArray,
42459
42465
  createUint8SharedArray: createUint8SharedArray,
42460
- decimate: decimate,
42466
+ decimate: decimate$1,
42461
42467
  deepMerge: deepMerge$1,
42462
42468
  eventListener: index$2,
42463
42469
  generateVolumePropsFromImageIds: generateVolumePropsFromImageIds,
@@ -44068,7 +44074,7 @@ class ProgressiveRetrieveImagesInstance {
44068
44074
  imageRequests.set(imageId, request);
44069
44075
  };
44070
44076
  for (const stage of this.stages) {
44071
- const indices = stage.positions || decimate(this.imageIds, stage.decimate || 1, stage.offset ?? 0);
44077
+ const indices = stage.positions || decimate$1(this.imageIds, stage.decimate || 1, stage.offset ?? 0);
44072
44078
  indices.forEach(index => addStageInstance(stage, index));
44073
44079
  }
44074
44080
  return interleaved;
@@ -44339,6 +44345,9 @@ class StackViewport extends Viewport$1 {
44339
44345
  this.getCurrentImageIdIndex = () => {
44340
44346
  return this.currentImageIdIndex;
44341
44347
  };
44348
+ this.getSliceIndex = () => {
44349
+ return this.currentImageIdIndex;
44350
+ };
44342
44351
  this.getTargetImageIdIndex = () => {
44343
44352
  return this.targetImageIdIndex;
44344
44353
  };
@@ -48496,6 +48505,32 @@ function getContourHolesDataCanvas(annotation, viewport) {
48496
48505
  return canvasHoleContours;
48497
48506
  }
48498
48507
 
48508
+ function distanceToPointSquaredInfo(lineStart, lineEnd, point) {
48509
+ let closestPoint;
48510
+ const distanceSquared = distanceToPointSquared(lineStart, lineEnd);
48511
+ if (lineStart[0] === lineEnd[0] && lineStart[1] === lineEnd[1]) {
48512
+ closestPoint = lineStart;
48513
+ }
48514
+ if (!closestPoint) {
48515
+ const dotProduct = ((point[0] - lineStart[0]) * (lineEnd[0] - lineStart[0]) + (point[1] - lineStart[1]) * (lineEnd[1] - lineStart[1])) / distanceSquared;
48516
+ if (dotProduct < 0) {
48517
+ closestPoint = lineStart;
48518
+ } else if (dotProduct > 1) {
48519
+ closestPoint = lineEnd;
48520
+ } else {
48521
+ closestPoint = [lineStart[0] + dotProduct * (lineEnd[0] - lineStart[0]), lineStart[1] + dotProduct * (lineEnd[1] - lineStart[1])];
48522
+ }
48523
+ }
48524
+ return {
48525
+ point: [...closestPoint],
48526
+ distanceSquared: distanceToPointSquared(point, closestPoint)
48527
+ };
48528
+ }
48529
+
48530
+ function distanceToPointSquared$1(lineStart, lineEnd, point) {
48531
+ return distanceToPointSquaredInfo(lineStart, lineEnd, point).distanceSquared;
48532
+ }
48533
+
48499
48534
  function distanceToPointSquared(p1, p2) {
48500
48535
  if (p1.length !== p2.length) {
48501
48536
  throw Error('Both points should have the same dimensionality');
@@ -48530,7 +48565,53 @@ function getWindingDirection(polyline) {
48530
48565
  return signedArea >= 0 ? 1 : -1;
48531
48566
  }
48532
48567
 
48533
- function updateContourPolyline(annotation, polylineData, transforms) {
48568
+ const DEFAULT_EPSILON = 0.1;
48569
+ function decimate(polyline, epsilon = DEFAULT_EPSILON) {
48570
+ const numPoints = polyline.length;
48571
+ if (numPoints < 3) {
48572
+ return polyline;
48573
+ }
48574
+ const epsilonSquared = epsilon * epsilon;
48575
+ const partitionQueue = [[0, numPoints - 1]];
48576
+ const polylinePointFlags = new Array(numPoints).fill(false);
48577
+ let numDecimatedPoints = 2;
48578
+ polylinePointFlags[0] = true;
48579
+ polylinePointFlags[numPoints - 1] = true;
48580
+ while (partitionQueue.length) {
48581
+ const [startIndex, endIndex] = partitionQueue.pop();
48582
+ if (endIndex - startIndex === 1) {
48583
+ continue;
48584
+ }
48585
+ const startPoint = polyline[startIndex];
48586
+ const endPoint = polyline[endIndex];
48587
+ let maxDistSquared = -Infinity;
48588
+ let maxDistIndex = -1;
48589
+ for (let i = startIndex + 1; i < endIndex; i++) {
48590
+ const currentPoint = polyline[i];
48591
+ const distSquared = distanceToPointSquared$1(startPoint, endPoint, currentPoint);
48592
+ if (distSquared > maxDistSquared) {
48593
+ maxDistSquared = distSquared;
48594
+ maxDistIndex = i;
48595
+ }
48596
+ }
48597
+ if (maxDistSquared < epsilonSquared) {
48598
+ continue;
48599
+ }
48600
+ polylinePointFlags[maxDistIndex] = true;
48601
+ numDecimatedPoints++;
48602
+ partitionQueue.push([maxDistIndex, endIndex]);
48603
+ partitionQueue.push([startIndex, maxDistIndex]);
48604
+ }
48605
+ const decimatedPolyline = new Array(numDecimatedPoints);
48606
+ for (let srcIndex = 0, dstIndex = 0; srcIndex < numPoints; srcIndex++) {
48607
+ if (polylinePointFlags[srcIndex]) {
48608
+ decimatedPolyline[dstIndex++] = polyline[srcIndex];
48609
+ }
48610
+ }
48611
+ return decimatedPolyline;
48612
+ }
48613
+
48614
+ function updateContourPolyline(annotation, polylineData, transforms, options) {
48534
48615
  const {
48535
48616
  canvasToWorld
48536
48617
  } = transforms;
@@ -48538,9 +48619,14 @@ function updateContourPolyline(annotation, polylineData, transforms) {
48538
48619
  data
48539
48620
  } = annotation;
48540
48621
  const {
48541
- points: polyline,
48542
48622
  targetWindingDirection
48543
48623
  } = polylineData;
48624
+ let {
48625
+ points: polyline
48626
+ } = polylineData;
48627
+ if (options?.decimate?.enabled) {
48628
+ polyline = decimate(polylineData.points, options?.decimate?.epsilon);
48629
+ }
48544
48630
  let {
48545
48631
  closed
48546
48632
  } = polylineData;