@cornerstonejs/adapters 0.4.0 → 0.4.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.
@@ -3531,21 +3531,26 @@ var MeasurementReport = /** @class */ (function () {
3531
3531
  });
3532
3532
  measurementGroups.forEach(function (measurementGroup) {
3533
3533
  var _a;
3534
- var measurementGroupContentSequence = toArray(measurementGroup.ContentSequence);
3535
- var TrackingIdentifierGroup = measurementGroupContentSequence.find(function (contentItem) {
3536
- return contentItem.ConceptNameCodeSequence.CodeMeaning ===
3537
- TRACKING_IDENTIFIER;
3538
- });
3539
- var TrackingIdentifierValue = TrackingIdentifierGroup.TextValue;
3540
- var toolClass = ((_a = hooks === null || hooks === void 0 ? void 0 : hooks.getToolClass) === null || _a === void 0 ? void 0 : _a.call(hooks, measurementGroup, dataset, registeredToolClasses)) ||
3541
- registeredToolClasses.find(function (tc) {
3542
- return tc.isValidCornerstoneTrackingIdentifier(TrackingIdentifierValue);
3534
+ try {
3535
+ var measurementGroupContentSequence = toArray(measurementGroup.ContentSequence);
3536
+ var TrackingIdentifierGroup = measurementGroupContentSequence.find(function (contentItem) {
3537
+ return contentItem.ConceptNameCodeSequence.CodeMeaning ===
3538
+ TRACKING_IDENTIFIER;
3543
3539
  });
3544
- if (toolClass) {
3545
- var measurement = toolClass.getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata);
3546
- console.log("=== ".concat(toolClass.toolType, " ==="));
3547
- console.log(measurement);
3548
- measurementData[toolClass.toolType].push(measurement);
3540
+ var TrackingIdentifierValue_1 = TrackingIdentifierGroup.TextValue;
3541
+ var toolClass = ((_a = hooks === null || hooks === void 0 ? void 0 : hooks.getToolClass) === null || _a === void 0 ? void 0 : _a.call(hooks, measurementGroup, dataset, registeredToolClasses)) ||
3542
+ registeredToolClasses.find(function (tc) {
3543
+ return tc.isValidCornerstoneTrackingIdentifier(TrackingIdentifierValue_1);
3544
+ });
3545
+ if (toolClass) {
3546
+ var measurement = toolClass.getMeasurementData(measurementGroup, sopInstanceUIDToImageIdMap, imageToWorldCoords, metadata);
3547
+ console.log("=== ".concat(toolClass.toolType, " ==="));
3548
+ console.log(measurement);
3549
+ measurementData[toolClass.toolType].push(measurement);
3550
+ }
3551
+ }
3552
+ catch (e) {
3553
+ console.warn("Unable to generate tool state for", measurementGroup, e);
3549
3554
  }
3550
3555
  });
3551
3556
  // NOTE: There is no way of knowing the cornerstone imageIds as that could be anything.
@@ -4115,14 +4120,25 @@ var EllipticalROI = /** @class */ (function () {
4115
4120
  EllipticalROI.getTID300RepresentationArguments = function (tool, worldToImageCoords) {
4116
4121
  var data = tool.data, finding = tool.finding, findingSites = tool.findingSites, metadata = tool.metadata;
4117
4122
  var _a = data.cachedStats, cachedStats = _a === void 0 ? {} : _a, handles = data.handles;
4123
+ var rotation = data.initialRotation || 0;
4118
4124
  var referencedImageId = metadata.referencedImageId;
4119
4125
  if (!referencedImageId) {
4120
4126
  throw new Error("EllipticalROI.getTID300RepresentationArguments: referencedImageId is not defined");
4121
4127
  }
4122
- var top = worldToImageCoords(referencedImageId, handles.points[0]);
4123
- var bottom = worldToImageCoords(referencedImageId, handles.points[1]);
4124
- var left = worldToImageCoords(referencedImageId, handles.points[2]);
4125
- var right = worldToImageCoords(referencedImageId, handles.points[3]);
4128
+ var top, bottom, left, right;
4129
+ // this way when it's restored we can assume the initial rotation is 0.
4130
+ if (rotation == 90 || rotation == 270) {
4131
+ bottom = worldToImageCoords(referencedImageId, handles.points[2]);
4132
+ top = worldToImageCoords(referencedImageId, handles.points[3]);
4133
+ left = worldToImageCoords(referencedImageId, handles.points[0]);
4134
+ right = worldToImageCoords(referencedImageId, handles.points[1]);
4135
+ }
4136
+ else {
4137
+ top = worldToImageCoords(referencedImageId, handles.points[0]);
4138
+ bottom = worldToImageCoords(referencedImageId, handles.points[1]);
4139
+ left = worldToImageCoords(referencedImageId, handles.points[2]);
4140
+ right = worldToImageCoords(referencedImageId, handles.points[3]);
4141
+ }
4126
4142
  // find the major axis and minor axis
4127
4143
  var topBottomLength = Math.abs(top[1] - bottom[1]);
4128
4144
  var leftRightLength = Math.abs(left[0] - right[0]);