@cornerstonejs/tools 1.7.2 → 1.8.1

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.
Files changed (32) hide show
  1. package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -0
  2. package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js +8 -0
  3. package/dist/cjs/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
  4. package/dist/cjs/stateManagement/segmentation/segmentationState.d.ts +2 -1
  5. package/dist/cjs/stateManagement/segmentation/segmentationState.js +9 -1
  6. package/dist/cjs/stateManagement/segmentation/segmentationState.js.map +1 -1
  7. package/dist/cjs/tools/segmentation/strategies/eraseRectangle.js +0 -3
  8. package/dist/cjs/tools/segmentation/strategies/eraseRectangle.js.map +1 -1
  9. package/dist/cjs/tools/segmentation/strategies/fillCircle.js +0 -3
  10. package/dist/cjs/tools/segmentation/strategies/fillCircle.js.map +1 -1
  11. package/dist/cjs/tools/segmentation/strategies/fillRectangle.js +0 -3
  12. package/dist/cjs/tools/segmentation/strategies/fillRectangle.js.map +1 -1
  13. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.d.ts +1 -0
  14. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js +8 -0
  15. package/dist/esm/stateManagement/segmentation/SegmentationStateManager.js.map +1 -1
  16. package/dist/esm/stateManagement/segmentation/segmentationState.d.ts +2 -1
  17. package/dist/esm/stateManagement/segmentation/segmentationState.js +8 -1
  18. package/dist/esm/stateManagement/segmentation/segmentationState.js.map +1 -1
  19. package/dist/esm/tools/segmentation/strategies/eraseRectangle.js +0 -3
  20. package/dist/esm/tools/segmentation/strategies/eraseRectangle.js.map +1 -1
  21. package/dist/esm/tools/segmentation/strategies/fillCircle.js +0 -3
  22. package/dist/esm/tools/segmentation/strategies/fillCircle.js.map +1 -1
  23. package/dist/esm/tools/segmentation/strategies/fillRectangle.js +0 -3
  24. package/dist/esm/tools/segmentation/strategies/fillRectangle.js.map +1 -1
  25. package/dist/umd/index.js +1 -1
  26. package/dist/umd/index.js.map +1 -1
  27. package/package.json +4 -3
  28. package/src/stateManagement/segmentation/SegmentationStateManager.ts +19 -0
  29. package/src/stateManagement/segmentation/segmentationState.ts +17 -0
  30. package/src/tools/segmentation/strategies/eraseRectangle.ts +0 -4
  31. package/src/tools/segmentation/strategies/fillCircle.ts +0 -4
  32. package/src/tools/segmentation/strategies/fillRectangle.ts +0 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "1.7.2",
3
+ "version": "1.8.1",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "main": "dist/umd/index.js",
6
6
  "types": "dist/esm/index.d.ts",
@@ -17,6 +17,7 @@
17
17
  "scripts": {
18
18
  "build:cjs": "tsc --project ./tsconfig.cjs.json",
19
19
  "build:esm": "tsc --project ./tsconfig.esm.json",
20
+ "build:esm:watch": "tsc --project ./tsconfig.esm.json --watch",
20
21
  "build:umd": "cross-env NODE_ENV=production webpack --config .webpack/webpack.prod.js",
21
22
  "build:all": "yarn run build:umd && yarn run build:cjs && yarn run build:esm",
22
23
  "build": "yarn run build:all",
@@ -28,7 +29,7 @@
28
29
  "webpack:watch": "webpack --mode development --progress --watch --config ./.webpack/webpack.dev.js"
29
30
  },
30
31
  "dependencies": {
31
- "@cornerstonejs/core": "^1.7.2",
32
+ "@cornerstonejs/core": "^1.8.1",
32
33
  "lodash.clonedeep": "4.5.0",
33
34
  "lodash.get": "^4.4.2"
34
35
  },
@@ -51,5 +52,5 @@
51
52
  "type": "individual",
52
53
  "url": "https://ohif.org/donate"
53
54
  },
54
- "gitHead": "8d996239bf6e2ce265a4d0bd6a5a6d8fe5e7122f"
55
+ "gitHead": "04ab5157739660d5bd012ae6c558afb01e9b3565"
55
56
  }
@@ -134,6 +134,25 @@ export default class SegmentationStateManager {
134
134
  return toolGroupSegRepresentationsWithConfig.segmentationRepresentations;
135
135
  }
136
136
 
137
+ /**
138
+ * Returns an array of all segmentation representations for all tool groups.
139
+ * @returns An array of ToolGroupSpecificRepresentations.
140
+ */
141
+ getAllSegmentationRepresentations(): Record<
142
+ string,
143
+ ToolGroupSpecificRepresentation[]
144
+ > {
145
+ const toolGroupSegReps: Record<string, ToolGroupSpecificRepresentation[]> =
146
+ {};
147
+ Object.entries(this.state.toolGroups).forEach(
148
+ ([toolGroupId, toolGroupSegRepresentationsWithConfig]) => {
149
+ toolGroupSegReps[toolGroupId] =
150
+ toolGroupSegRepresentationsWithConfig.segmentationRepresentations;
151
+ }
152
+ );
153
+ return toolGroupSegReps;
154
+ }
155
+
137
156
  /**
138
157
  * Add a new segmentation representation to the toolGroup's segmentation representations.
139
158
  * @param toolGroupId - The Id of the tool group .
@@ -85,6 +85,18 @@ function getSegmentationRepresentations(
85
85
  return segmentationStateManager.getSegmentationRepresentations(toolGroupId);
86
86
  }
87
87
 
88
+ /**
89
+ * Get all segmentation representations in the state
90
+ * @returns An array of segmentation representation objects.
91
+ */
92
+ function getAllSegmentationRepresentations(): Record<
93
+ string,
94
+ ToolGroupSpecificRepresentation[]
95
+ > {
96
+ const segmentationStateManager = getDefaultSegmentationStateManager();
97
+ return segmentationStateManager.getAllSegmentationRepresentations();
98
+ }
99
+
88
100
  /**
89
101
  * Get the tool group IDs that have a segmentation representation with the given
90
102
  * segmentationId
@@ -92,6 +104,10 @@ function getSegmentationRepresentations(
92
104
  * @returns An array of tool group IDs.
93
105
  */
94
106
  function getToolGroupIdsWithSegmentation(segmentationId: string): string[] {
107
+ if (!segmentationId) {
108
+ throw new Error('getToolGroupIdsWithSegmentation: segmentationId is empty');
109
+ }
110
+
95
111
  const segmentationStateManager = getDefaultSegmentationStateManager();
96
112
  const state = segmentationStateManager.getState();
97
113
  const toolGroupIds = Object.keys(state.toolGroups);
@@ -405,6 +421,7 @@ export {
405
421
  setSegmentSpecificRepresentationConfig,
406
422
  // helpers s
407
423
  getToolGroupIdsWithSegmentation,
424
+ getAllSegmentationRepresentations,
408
425
  getSegmentationRepresentationByUID,
409
426
  // color
410
427
  addColorLUT,
@@ -35,10 +35,6 @@ function eraseRectangle(
35
35
 
36
36
  const boundsIJK = getBoundingBoxAroundShape(rectangleCornersIJK, dimensions);
37
37
 
38
- if (boundsIJK.every(([min, max]) => min !== max)) {
39
- throw new Error('Oblique segmentation tools are not supported yet');
40
- }
41
-
42
38
  // Since always all points inside the boundsIJK is inside the rectangle...
43
39
  const pointInShape = () => true;
44
40
 
@@ -68,10 +68,6 @@ function fillCircle(
68
68
 
69
69
  const boundsIJK = getBoundingBoxAroundShape(ellipsoidCornersIJK, dimensions);
70
70
 
71
- if (boundsIJK.every(([min, max]) => min !== max)) {
72
- throw new Error('Oblique segmentation tools are not supported yet');
73
- }
74
-
75
71
  // using circle as a form of ellipse
76
72
  const ellipseObj = {
77
73
  center: center as Types.Point3,
@@ -54,10 +54,6 @@ function fillRectangle(
54
54
 
55
55
  const boundsIJK = getBoundingBoxAroundShape(rectangleCornersIJK, dimensions);
56
56
 
57
- if (boundsIJK.every(([min, max]) => min !== max)) {
58
- throw new Error('Oblique segmentation tools are not supported yet');
59
- }
60
-
61
57
  // Since always all points inside the boundsIJK is inside the rectangle...
62
58
  const pointInRectangle = () => true;
63
59