@cornerstonejs/adapters 1.52.0 → 1.53.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 +109 -1
- package/dist/adapters.es.js.map +1 -1
- package/package.json +5 -5
package/dist/adapters.es.js
CHANGED
|
@@ -48370,6 +48370,100 @@ let AnnotationToPointData$1 = class AnnotationToPointData {
|
|
|
48370
48370
|
AnnotationToPointData$1.register(RectangleROIStartEndThreshold$1);
|
|
48371
48371
|
var AnnotationToPointData$2 = AnnotationToPointData$1;
|
|
48372
48372
|
|
|
48373
|
+
function getContourHolesDataWorld(annotation) {
|
|
48374
|
+
const childAnnotationUIDs = annotation.childAnnotationUIDs ?? [];
|
|
48375
|
+
return childAnnotationUIDs.map(uid => getAnnotation(uid).data.contour.polyline);
|
|
48376
|
+
}
|
|
48377
|
+
|
|
48378
|
+
function getContourHolesDataCanvas(annotation, viewport) {
|
|
48379
|
+
const worldHoleContours = getContourHolesDataWorld(annotation);
|
|
48380
|
+
const canvasHoleContours = [];
|
|
48381
|
+
worldHoleContours.forEach(worldHoleContour => {
|
|
48382
|
+
const numPoints = worldHoleContour.length;
|
|
48383
|
+
const canvasHoleContour = new Array(numPoints);
|
|
48384
|
+
for (let i = 0; i < numPoints; i++) {
|
|
48385
|
+
canvasHoleContour[i] = viewport.worldToCanvas(worldHoleContour[i]);
|
|
48386
|
+
}
|
|
48387
|
+
canvasHoleContours.push(canvasHoleContour);
|
|
48388
|
+
});
|
|
48389
|
+
return canvasHoleContours;
|
|
48390
|
+
}
|
|
48391
|
+
|
|
48392
|
+
function distanceToPointSquared(p1, p2) {
|
|
48393
|
+
if (p1.length !== p2.length) {
|
|
48394
|
+
throw Error('Both points should have the same dimensionality');
|
|
48395
|
+
}
|
|
48396
|
+
const [x1, y1, z1 = 0] = p1;
|
|
48397
|
+
const [x2, y2, z2 = 0] = p2;
|
|
48398
|
+
const dx = x2 - x1;
|
|
48399
|
+
const dy = y2 - y1;
|
|
48400
|
+
const dz = z2 - z1;
|
|
48401
|
+
return dx * dx + dy * dy + dz * dz;
|
|
48402
|
+
}
|
|
48403
|
+
|
|
48404
|
+
function getSignedArea(polyline) {
|
|
48405
|
+
const refPoint = polyline[0];
|
|
48406
|
+
let area = 0;
|
|
48407
|
+
for (let i = 0, len = polyline.length; i < len; i++) {
|
|
48408
|
+
const p1 = polyline[i];
|
|
48409
|
+
const p2Index = i === len - 1 ? 0 : i + 1;
|
|
48410
|
+
const p2 = polyline[p2Index];
|
|
48411
|
+
const aX = p1[0] - refPoint[0];
|
|
48412
|
+
const aY = p1[1] - refPoint[1];
|
|
48413
|
+
const bX = p2[0] - refPoint[0];
|
|
48414
|
+
const bY = p2[1] - refPoint[1];
|
|
48415
|
+
area += aX * bY - aY * bX;
|
|
48416
|
+
}
|
|
48417
|
+
area *= 0.5;
|
|
48418
|
+
return area;
|
|
48419
|
+
}
|
|
48420
|
+
|
|
48421
|
+
function getWindingDirection(polyline) {
|
|
48422
|
+
const signedArea = getSignedArea(polyline);
|
|
48423
|
+
return signedArea >= 0 ? 1 : -1;
|
|
48424
|
+
}
|
|
48425
|
+
|
|
48426
|
+
function updateContourPolyline(annotation, polylineData, transforms) {
|
|
48427
|
+
const {
|
|
48428
|
+
canvasToWorld
|
|
48429
|
+
} = transforms;
|
|
48430
|
+
const {
|
|
48431
|
+
data
|
|
48432
|
+
} = annotation;
|
|
48433
|
+
const {
|
|
48434
|
+
points: polyline,
|
|
48435
|
+
targetWindingDirection
|
|
48436
|
+
} = polylineData;
|
|
48437
|
+
let {
|
|
48438
|
+
closed
|
|
48439
|
+
} = polylineData;
|
|
48440
|
+
const numPoints = polyline.length;
|
|
48441
|
+
const polylineWorldPoints = new Array(numPoints);
|
|
48442
|
+
const currentWindingDirection = getWindingDirection(polyline);
|
|
48443
|
+
const parentAnnotation = getParentAnnotation(annotation);
|
|
48444
|
+
if (closed === undefined) {
|
|
48445
|
+
let currentClosedState = false;
|
|
48446
|
+
if (polyline.length > 3) {
|
|
48447
|
+
const lastToFirstDist = distanceToPointSquared(polyline[0], polyline[numPoints - 1]);
|
|
48448
|
+
currentClosedState = isEqual$2(0, lastToFirstDist);
|
|
48449
|
+
}
|
|
48450
|
+
closed = currentClosedState;
|
|
48451
|
+
}
|
|
48452
|
+
let windingDirection = parentAnnotation ? parentAnnotation.data.contour.windingDirection * -1 : targetWindingDirection;
|
|
48453
|
+
if (windingDirection === undefined) {
|
|
48454
|
+
windingDirection = currentWindingDirection;
|
|
48455
|
+
} else if (windingDirection !== currentWindingDirection) {
|
|
48456
|
+
polyline.reverse();
|
|
48457
|
+
}
|
|
48458
|
+
for (let i = 0; i < numPoints; i++) {
|
|
48459
|
+
polylineWorldPoints[i] = canvasToWorld(polyline[i]);
|
|
48460
|
+
}
|
|
48461
|
+
data.contour.polyline = polylineWorldPoints;
|
|
48462
|
+
data.contour.closed = closed;
|
|
48463
|
+
data.contour.windingDirection = windingDirection;
|
|
48464
|
+
invalidateAnnotation(annotation);
|
|
48465
|
+
}
|
|
48466
|
+
|
|
48373
48467
|
function getInterpolationData(viewportData, filterParams = []) {
|
|
48374
48468
|
const {
|
|
48375
48469
|
viewport,
|
|
@@ -49332,8 +49426,11 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
49332
49426
|
detectContourHoles: detectContourHoles,
|
|
49333
49427
|
findHandlePolylineIndex: findHandlePolylineIndex,
|
|
49334
49428
|
generateContourSetsFromLabelmap: generateContourSetsFromLabelmap$2,
|
|
49429
|
+
getContourHolesDataCanvas: getContourHolesDataCanvas,
|
|
49430
|
+
getContourHolesDataWorld: getContourHolesDataWorld,
|
|
49335
49431
|
interpolation: index$1,
|
|
49336
|
-
mergePoints: mergePoints
|
|
49432
|
+
mergePoints: mergePoints,
|
|
49433
|
+
updateContourPolyline: updateContourPolyline
|
|
49337
49434
|
});
|
|
49338
49435
|
|
|
49339
49436
|
const MODES = [ToolModes$1.Active, ToolModes$1.Passive, ToolModes$1.Enabled];
|
|
@@ -49421,6 +49518,9 @@ function getAnnotations(toolName, annotationGroupSelector) {
|
|
|
49421
49518
|
const groupKey = manager.getGroupKey(annotationGroupSelector);
|
|
49422
49519
|
return manager.getAnnotations(groupKey, toolName);
|
|
49423
49520
|
}
|
|
49521
|
+
function getParentAnnotation(annotation) {
|
|
49522
|
+
return annotation.parentAnnotationUID ? getAnnotation(annotation.parentAnnotationUID) : undefined;
|
|
49523
|
+
}
|
|
49424
49524
|
function addAnnotation(annotation, annotationGroupSelector) {
|
|
49425
49525
|
if (!annotation.annotationUID) {
|
|
49426
49526
|
annotation.annotationUID = uuidv4$1();
|
|
@@ -49445,6 +49545,7 @@ function removeAnnotation(annotationUID) {
|
|
|
49445
49545
|
if (!annotation) {
|
|
49446
49546
|
return;
|
|
49447
49547
|
}
|
|
49548
|
+
annotation.childAnnotationUIDs?.forEach(childAnnotationUID => removeAnnotation(childAnnotationUID));
|
|
49448
49549
|
manager.removeAnnotation(annotationUID);
|
|
49449
49550
|
const eventType = Events$1.ANNOTATION_REMOVED;
|
|
49450
49551
|
const eventDetail = {
|
|
@@ -49458,6 +49559,13 @@ function getAnnotation(annotationUID) {
|
|
|
49458
49559
|
const annotation = manager.getAnnotation(annotationUID);
|
|
49459
49560
|
return annotation;
|
|
49460
49561
|
}
|
|
49562
|
+
function invalidateAnnotation(annotation) {
|
|
49563
|
+
let currAnnotation = annotation;
|
|
49564
|
+
while (currAnnotation) {
|
|
49565
|
+
currAnnotation.invalidated = true;
|
|
49566
|
+
currAnnotation = currAnnotation.parentAnnotationUID ? getAnnotation(currAnnotation.parentAnnotationUID) : undefined;
|
|
49567
|
+
}
|
|
49568
|
+
}
|
|
49461
49569
|
|
|
49462
49570
|
function getPatientModule(imageId, metadataProvider) {
|
|
49463
49571
|
var generalSeriesModule = metadataProvider.get("generalSeriesModule", imageId);
|