@cornerstonejs/tools 5.10.3 → 5.10.4

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.
@@ -9,6 +9,7 @@ import { computeAndAddRepresentation } from '../../../utilities/segmentation/com
9
9
  import { internalGetHiddenSegmentIndices } from '../../../stateManagement/segmentation/helpers/internalGetHiddenSegmentIndices.js';
10
10
  import { utilities as cornerstoneUtilities } from '@cornerstonejs/core';
11
11
  const cs3dLogger = cornerstoneUtilities.logger.toolsLog.getLogger('tools.displayTools.Surface.surfaceDisplay');
12
+ const polySegConversionBySegmentation = new Map();
12
13
  function removeRepresentation(viewportId, segmentationId, renderImmediate = false) {
13
14
  const enabledElement = getEnabledElementByViewportId(viewportId);
14
15
  if (!enabledElement) {
@@ -31,10 +32,14 @@ async function render(viewport, representation) {
31
32
  if (!SurfaceData &&
32
33
  getPolySeg()?.canComputeRequestedRepresentation(segmentationId, Representations.Surface)) {
33
34
  const polySeg = getPolySeg();
34
- SurfaceData = await computeAndAddRepresentation(segmentationId, Representations.Surface, () => polySeg.computeSurfaceData(segmentationId, { viewport }));
35
- if (!SurfaceData) {
36
- throw new Error(`No Surface data found for segmentationId ${segmentationId} even we tried to compute it`);
35
+ let conversion = polySegConversionBySegmentation.get(segmentationId);
36
+ if (!conversion) {
37
+ conversion = computeAndAddRepresentation(segmentationId, Representations.Surface, () => polySeg.computeSurfaceData(segmentationId, { viewport })).finally(() => {
38
+ polySegConversionBySegmentation.delete(segmentationId);
39
+ });
40
+ polySegConversionBySegmentation.set(segmentationId, conversion);
37
41
  }
42
+ SurfaceData = await conversion;
38
43
  }
39
44
  else if (!SurfaceData && !getPolySeg()) {
40
45
  cs3dLogger.debug(`No surface data found for segmentationId ${segmentationId} and PolySeg add-on is not configured. Unable to convert from other representations to surface. Please register PolySeg using cornerstoneTools.init({ addons: { polySeg } }) to enable automatic conversion.`);
@@ -1 +1 @@
1
- export declare const version = "5.10.3";
1
+ export declare const version = "5.10.4";
@@ -1 +1 @@
1
- export const version = '5.10.3';
1
+ export const version = '5.10.4';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cornerstonejs/tools",
3
- "version": "5.10.3",
3
+ "version": "5.10.4",
4
4
  "description": "Cornerstone3D Tools",
5
5
  "types": "./dist/esm/index.d.ts",
6
6
  "module": "./dist/esm/index.js",
@@ -126,11 +126,11 @@
126
126
  "lodash.get": "4.4.2"
127
127
  },
128
128
  "devDependencies": {
129
- "@cornerstonejs/core": "5.10.3",
129
+ "@cornerstonejs/core": "5.10.4",
130
130
  "canvas": "3.2.0"
131
131
  },
132
132
  "peerDependencies": {
133
- "@cornerstonejs/core": "5.10.3",
133
+ "@cornerstonejs/core": "5.10.4",
134
134
  "@kitware/vtk.js": "36.4.1",
135
135
  "@types/d3-array": "3.2.1",
136
136
  "@types/d3-interpolate": "3.0.4",