@cornerstonejs/tools 1.47.4 → 1.48.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "1.47.4",
3
+ "version": "1.48.0",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "src/index.ts",
6
6
  "types": "dist/types/index.d.ts",
@@ -29,7 +29,7 @@
29
29
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
30
30
  },
31
31
  "dependencies": {
32
- "@cornerstonejs/core": "^1.47.4",
32
+ "@cornerstonejs/core": "^1.48.0",
33
33
  "comlink": "^4.4.1",
34
34
  "lodash.clonedeep": "4.5.0",
35
35
  "lodash.get": "^4.4.2"
@@ -53,5 +53,5 @@
53
53
  "type": "individual",
54
54
  "url": "https://ohif.org/donate"
55
55
  },
56
- "gitHead": "659f9ca5a410b3e915b0ac95c61765cfd061be8d"
56
+ "gitHead": "ace7497b03ab306f179a3673f25a575c3152fc9e"
57
57
  }
@@ -4,21 +4,41 @@ import { getSegmentationRepresentations } from '../../../stateManagement/segment
4
4
  import { ToolGroupSpecificRepresentation } from '../../../types/SegmentationStateTypes';
5
5
  import { triggerSegmentationRepresentationModified } from '../triggerSegmentationEvents';
6
6
  import SegmentationRepresentations from '../../../enums/SegmentationRepresentations';
7
+ import { isVolumeSegmentation } from '../../../tools/segmentation/strategies/utils/stackVolumeCheck';
7
8
 
8
9
  function getUniqueSegmentIndices(segmentationId) {
9
10
  const segmentation = SegmentationState.getSegmentation(segmentationId);
10
11
 
11
12
  if (segmentation.type === SegmentationRepresentations.Labelmap) {
12
- const volume = cache.getVolume(segmentationId);
13
- const scalarData = volume.getScalarData();
13
+ const labelmapData =
14
+ segmentation.representationData[SegmentationRepresentations.Labelmap];
14
15
 
15
16
  const keySet = {};
16
- for (let i = 0; i < scalarData.length; i++) {
17
- const segmentIndex = scalarData[i];
18
- if (segmentIndex !== 0 && !keySet[segmentIndex]) {
19
- keySet[segmentIndex] = true;
17
+
18
+ if (isVolumeSegmentation(labelmapData)) {
19
+ const volume = cache.getVolume(segmentationId);
20
+ const scalarData = volume.getScalarData();
21
+
22
+ for (let i = 0; i < scalarData.length; i++) {
23
+ const segmentIndex = scalarData[i];
24
+ if (segmentIndex !== 0 && !keySet[segmentIndex]) {
25
+ keySet[segmentIndex] = true;
26
+ }
20
27
  }
28
+ } else {
29
+ labelmapData.imageIdReferenceMap.forEach((segmentationImageId) => {
30
+ const image = cache.getImage(segmentationImageId);
31
+ const scalarData = image.getPixelData();
32
+
33
+ for (let i = 0; i < scalarData.length; i++) {
34
+ const segmentIndex = scalarData[i];
35
+ if (segmentIndex !== 0 && !keySet[segmentIndex]) {
36
+ keySet[segmentIndex] = true;
37
+ }
38
+ }
39
+ });
21
40
  }
41
+
22
42
  return Object.keys(keySet).map((it) => parseInt(it, 10));
23
43
  } else if (segmentation.type === SegmentationRepresentations.Contour) {
24
44
  const annotationUIDsMap =
@@ -3,6 +3,7 @@ import {
3
3
  getEnabledElement,
4
4
  triggerEvent,
5
5
  eventTarget,
6
+ utilities as csUtils,
6
7
  } from '@cornerstonejs/core';
7
8
  import type { Types } from '@cornerstonejs/core';
8
9
 
@@ -823,7 +824,15 @@ class AngleTool extends AnnotationTool {
823
824
  [worldPos1, worldPos2],
824
825
  [worldPos2, worldPos3]
825
826
  );
827
+ const { dimensions, imageData } = this.getTargetIdImage(
828
+ targetId,
829
+ renderingEngine
830
+ );
826
831
 
832
+ // Decide if there's at least one handle is outside of image
833
+ this.isHandleOutsideImage = [worldPos1, worldPos2, worldPos3]
834
+ .map((worldPos) => csUtils.transformWorldToIndex(imageData, worldPos))
835
+ .some((index) => !csUtils.indexWithinDimensions(index, dimensions));
827
836
  cachedStats[targetId] = {
828
837
  angle: isNaN(angle) ? 'Incomplete Angle' : angle,
829
838
  };