@cornerstonejs/adapters 1.54.2 → 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.
- package/dist/adapters.es.js +82 -5
- package/dist/adapters.es.js.map +1 -1
- package/package.json +5 -5
package/dist/adapters.es.js
CHANGED
|
@@ -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);
|
|
@@ -42463,7 +42463,7 @@ var utilities = /*#__PURE__*/Object.freeze({
|
|
|
42463
42463
|
createSigmoidRGBTransferFunction: createSigmoidRGBTransferFunction,
|
|
42464
42464
|
createUint16SharedArray: createUint16SharedArray,
|
|
42465
42465
|
createUint8SharedArray: createUint8SharedArray,
|
|
42466
|
-
decimate: decimate,
|
|
42466
|
+
decimate: decimate$1,
|
|
42467
42467
|
deepMerge: deepMerge$1,
|
|
42468
42468
|
eventListener: index$2,
|
|
42469
42469
|
generateVolumePropsFromImageIds: generateVolumePropsFromImageIds,
|
|
@@ -44074,7 +44074,7 @@ class ProgressiveRetrieveImagesInstance {
|
|
|
44074
44074
|
imageRequests.set(imageId, request);
|
|
44075
44075
|
};
|
|
44076
44076
|
for (const stage of this.stages) {
|
|
44077
|
-
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);
|
|
44078
44078
|
indices.forEach(index => addStageInstance(stage, index));
|
|
44079
44079
|
}
|
|
44080
44080
|
return interleaved;
|
|
@@ -48505,6 +48505,32 @@ function getContourHolesDataCanvas(annotation, viewport) {
|
|
|
48505
48505
|
return canvasHoleContours;
|
|
48506
48506
|
}
|
|
48507
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
|
+
|
|
48508
48534
|
function distanceToPointSquared(p1, p2) {
|
|
48509
48535
|
if (p1.length !== p2.length) {
|
|
48510
48536
|
throw Error('Both points should have the same dimensionality');
|
|
@@ -48539,7 +48565,53 @@ function getWindingDirection(polyline) {
|
|
|
48539
48565
|
return signedArea >= 0 ? 1 : -1;
|
|
48540
48566
|
}
|
|
48541
48567
|
|
|
48542
|
-
|
|
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) {
|
|
48543
48615
|
const {
|
|
48544
48616
|
canvasToWorld
|
|
48545
48617
|
} = transforms;
|
|
@@ -48547,9 +48619,14 @@ function updateContourPolyline(annotation, polylineData, transforms) {
|
|
|
48547
48619
|
data
|
|
48548
48620
|
} = annotation;
|
|
48549
48621
|
const {
|
|
48550
|
-
points: polyline,
|
|
48551
48622
|
targetWindingDirection
|
|
48552
48623
|
} = polylineData;
|
|
48624
|
+
let {
|
|
48625
|
+
points: polyline
|
|
48626
|
+
} = polylineData;
|
|
48627
|
+
if (options?.decimate?.enabled) {
|
|
48628
|
+
polyline = decimate(polylineData.points, options?.decimate?.epsilon);
|
|
48629
|
+
}
|
|
48553
48630
|
let {
|
|
48554
48631
|
closed
|
|
48555
48632
|
} = polylineData;
|